Save and display creator of Order

This commit is contained in:
Julius 2012-11-12 14:24:49 +01:00
parent 69c4fc5817
commit c17ff281c3
8 changed files with 25 additions and 4 deletions

View file

@ -11,13 +11,17 @@ class Order < ActiveRecord::Base
has_many :comments, :class_name => "OrderComment", :order => "created_at"
has_many :stock_changes
belongs_to :supplier
belongs_to :updated_by, :class_name => "User", :foreign_key => "updated_by_user_id"
belongs_to :updated_by, :class_name => 'User', :foreign_key => 'updated_by_user_id'
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_user_id'
# Validations
validates_presence_of :starts
validate :starts_before_ends, :include_articles
# Callbacks
before_create do |order|
order.created_by = User.current_user
end
after_update :update_price_of_group_orders
# Finders