diff options
| author | Kir Shatrov | 2012-01-17 04:06:10 -0800 |
|---|---|---|
| committer | Kir Shatrov | 2012-01-17 04:06:10 -0800 |
| commit | a49705dffc625f08577f5ce0acaf6b75ae2abef6 (patch) | |
| tree | 42a2fe5c1068b8ca054664d11523cded1a2c6238 /lib | |
| parent | bbde9b7d0fc69d738634e47afd5925b1515cf9ee (diff) | |
| parent | 69127502f3a419beecd35dda687f5536524a4d7a (diff) | |
| download | inboxes-a49705dffc625f08577f5ce0acaf6b75ae2abef6.tar.bz2 | |
Merge pull request #9 from alec-c4/master
discussable
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/generators/inboxes/templates/install.rb | 3 | ||||
| -rw-r--r-- | lib/inboxes/active_record_extension.rb | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/generators/inboxes/templates/install.rb b/lib/generators/inboxes/templates/install.rb index 436ac98..e89c128 100644 --- a/lib/generators/inboxes/templates/install.rb +++ b/lib/generators/inboxes/templates/install.rb @@ -2,6 +2,7 @@ class InstallInboxes < ActiveRecord::Migration def self.up create_table :discussions do |t| t.integer :messages_count, :default => 0 # counter cache + t.references :discussable t.timestamps end @@ -26,4 +27,4 @@ class InstallInboxes < ActiveRecord::Migration drop_table :discussions drop_table :messages end -end
\ No newline at end of file +end diff --git a/lib/inboxes/active_record_extension.rb b/lib/inboxes/active_record_extension.rb index 2a5bac8..d6e7e36 100644 --- a/lib/inboxes/active_record_extension.rb +++ b/lib/inboxes/active_record_extension.rb @@ -7,5 +7,9 @@ module Inboxes has_many :speakers, :dependent => :destroy has_many :discussions, :through => :speakers end + + def acts_as_discussable + has_many :discussions, :as => :discussable + end end -end
\ No newline at end of file +end |
