]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/diary_entry.rb
more idiomatic models for diary entry subscriptions
[rails.git] / app / models / diary_entry.rb
index 07bb60a1096e17f725ac5b8e1e968e012772c7f2..48f3e69bdad646eaa766efe3d6dc44f83207a1a9 100644 (file)
@@ -4,7 +4,8 @@ class DiaryEntry < ActiveRecord::Base
 
   has_many :comments, -> { order(:id).preload(:user) }, :class_name => "DiaryComment"
   has_many :visible_comments, -> { joins(:user).where(:visible => true, :users => { :status => %w(active confirmed) }).order(:id) }, :class_name => "DiaryComment"
-  has_and_belongs_to_many :subscribers, :class_name => "User", :join_table => "diary_entries_subscribers", :association_foreign_key => "subscriber_id"
+  has_many :subscriptions, :class_name => 'DiaryEntrySubscription'
+  has_many :subscribers, :through => :subscriptions, :source => :user
 
   scope :visible, -> { where(:visible => true) }