changed to/from to recipient/sender

This commit is contained in:
Skud committed 2013-02-16 00:28:31 +11:00
1 parent 4516a2f099
commit 528a5ce32c
11 files changed
+33 -25

No files matched your search

+2 -2
View File
@@ -13,8 +13,8 @@ class Ability
can :update, Member, :id => member.id
# can read/delete notifications that were sent to them
can :read, Notification, :to_id => member.id
can :destroy, Notification, :to_id => member.id
can :read, Notification, :recipient_id => member.id
can :destroy, Notification, :recipient_id => member.id
# note we don't support create/update for notifications
# for now, anyone can create/edit/destroy crops
+2 -2
View File
@@ -5,8 +5,8 @@ class Comment < ActiveRecord::Base
after_create {
Notification.create(
:to_id => self.post.author.id,
:from_id => self.author.id,
:recipient_id => self.post.author.id,
:sender_id => self.author.id,
:subject => "New comment on #{self.post.subject}",
:body => self.body,
:post_id => self.post.id
+2 -2
View File
@@ -5,8 +5,8 @@ class Member < ActiveRecord::Base
has_many :posts, :foreign_key => 'author_id'
has_many :comments, :foreign_key => 'author_id'
has_many :gardens, :foreign_key => 'owner_id'
has_many :notifications, :foreign_key => 'to_id'
has_many :sent_notifications, :foreign_key => 'from_id'
has_many :notifications, :foreign_key => 'recipient_id'
has_many :sent_notifications, :foreign_key => 'sender_id'
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
+3 -3
View File
@@ -1,9 +1,9 @@
class Notification < ActiveRecord::Base
attr_accessible :to_id, :from_id,
attr_accessible :sender_id, :recipient_id,
:subject, :body, :post_id, :read
belongs_to :sender, :class_name => 'Member', :foreign_key => 'from_id'
belongs_to :recipient, :class_name => 'Member', :foreign_key => 'to_id'
belongs_to :sender, :class_name => 'Member'
belongs_to :recipient, :class_name => 'Member'
belongs_to :post
end
+2 -2
View File
@@ -14,8 +14,8 @@
- @notifications.each do |notification|
%tr
%td= notification.from_id
%td= notification.to_id
%td= notification.sender_id
%td= notification.recipient_id
%td= notification.subject
%td= notification.body
%td= notification.read
+2 -2
View File
@@ -2,10 +2,10 @@
%p
%b From:
= @notification.from_id
= @notification.sender_id
%p
%b To:
= @notification.to_id
= @notification.recipient_id
%p
%b Subject:
= @notification.subject
@@ -0,0 +1,8 @@
class RenameNotificationFields < ActiveRecord::Migration
def change
change_table :notifications do |t|
t.rename :to_id, :recipient_id
t.rename :from_id, :sender_id
end
end
end
+5 -5
View File
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130212123628) do
ActiveRecord::Schema.define(:version => 20130215131921) do
create_table "comments", :force => true do |t|
t.integer "post_id", :null => false
@@ -77,14 +77,14 @@ ActiveRecord::Schema.define(:version => 20130212123628) do
add_index "members", ["unlock_token"], :name => "index_users_on_unlock_token", :unique => true
create_table "notifications", :force => true do |t|
t.integer "from_id"
t.integer "to_id", :null => false
t.integer "sender_id"
t.integer "recipient_id", :null => false
t.string "subject"
t.text "body"
t.boolean "read"
t.integer "post_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "plantings", :force => true do |t|
@@ -5,7 +5,7 @@ describe NotificationsController do
login_member
def valid_attributes
{ "to_id" => subject.current_member.id }
{ "recipient_id" => subject.current_member.id }
end
def valid_session
@@ -4,16 +4,16 @@ describe "notifications/index" do
before(:each) do
assign(:notifications, [
stub_model(Notification,
:from_id => 1,
:to_id => 2,
:sender_id => 1,
:recipient_id => 2,
:subject => "Subject",
:body => "MyText",
:read => false,
:post_id => 4
),
stub_model(Notification,
:from_id => 1,
:to_id => 2,
:sender_id => 1,
:recipient_id => 2,
:subject => "Subject",
:body => "MyText",
:read => false,
@@ -3,8 +3,8 @@ require 'spec_helper'
describe "notifications/show" do
before(:each) do
@notification = assign(:notification, stub_model(Notification,
:from_id => 1,
:to_id => 2,
:sender_id => 1,
:recipient_id => 2,
:subject => "Subject",
:body => "MyText",
:read => false,