2011-07-12 16:37:16 -07:00
|
|
|
class ClosetHanger < ActiveRecord::Base
|
|
|
|
belongs_to :item
|
|
|
|
belongs_to :user
|
|
|
|
|
2011-07-14 09:50:24 -07:00
|
|
|
attr_accessible :quantity
|
|
|
|
|
|
|
|
validates :item_id, :uniqueness => {:scope => :user_id}
|
|
|
|
validates :quantity, :numericality => {:greater_than => 0}
|
|
|
|
validates_presence_of :item, :user
|
|
|
|
|
2011-07-12 16:37:16 -07:00
|
|
|
scope :alphabetical_by_item_name, joins(:item).order(Item.arel_table[:name])
|
|
|
|
end
|
|
|
|
|