Improve associations

This commit is contained in:
wvengen 2015-04-10 18:30:12 +02:00
parent 124f77f2ab
commit 497488ef0e
2 changed files with 2 additions and 3 deletions

View file

@ -8,6 +8,7 @@ class Order < ActiveRecord::Base
has_many :articles, :through => :order_articles
has_many :group_orders, :dependent => :destroy
has_many :ordergroups, :through => :group_orders
has_many :users_ordered, :through => :ordergroups, :source => :users
has_one :invoice
has_many :comments, -> { order('created_at') }, :class_name => "OrderComment"
has_many :stock_changes

View file

@ -42,9 +42,7 @@ class Message < ActiveRecord::Base
def order_id=(order_id)
@order_id = order_id
for ordergroup in Order.find(order_id).ordergroups
add_recipients ordergroup.users
end
add_recipients Order.find(order_id).users_ordered unless order_id.blank?
end
def recipient_tokens=(ids)