|
@ -1,6 +1,6 @@ |
|
|
class Bike < ActiveRecord::Base |
|
|
class Bike < ActiveRecord::Base |
|
|
acts_as_loggable |
|
|
acts_as_loggable |
|
|
attr_accessible :shop_id, :serial_number, :bike_brand_id, :bike_model_id, :color, :bike_style_id, :seat_tube_height, |
|
|
attr_accessible :shop_id, :serial_number, :bike_brand_id, :model, :color, :bike_style_id, :seat_tube_height, |
|
|
:top_tube_length, :wheel_size, :value, :bike_condition_id, :bike_purpose_id |
|
|
:top_tube_length, :wheel_size, :value, :bike_condition_id, :bike_purpose_id |
|
|
|
|
|
|
|
|
has_many :transactions |
|
|
has_many :transactions |
|
@ -8,15 +8,14 @@ class Bike < ActiveRecord::Base |
|
|
has_one :owner, :class_name => 'User' |
|
|
has_one :owner, :class_name => 'User' |
|
|
has_one :task_list, :as => :item, :dependent => :destroy |
|
|
has_one :task_list, :as => :item, :dependent => :destroy |
|
|
belongs_to :bike_brand |
|
|
belongs_to :bike_brand |
|
|
belongs_to :bike_model |
|
|
|
|
|
belongs_to :bike_style |
|
|
belongs_to :bike_style |
|
|
belongs_to :bike_condition |
|
|
belongs_to :bike_condition |
|
|
belongs_to :bike_purpose |
|
|
belongs_to :bike_purpose |
|
|
|
|
|
|
|
|
validates :shop_id, :presence => true, :uniqueness => true, :length => { :minimum => 3 } |
|
|
validates :shop_id, :presence => true, :uniqueness => true, :length => { :minimum => 3 } |
|
|
validates :serial_number, :length => { :minimum => 3 } |
|
|
validates :serial_number, :length => { :minimum => 3 } |
|
|
|
|
|
validates :model, :length => { :maximum => 50 } |
|
|
validates :bike_brand_id, :presence => true |
|
|
validates :bike_brand_id, :presence => true |
|
|
validates :bike_model_id, :presence => true |
|
|
|
|
|
validates :color, :presence => true |
|
|
validates :color, :presence => true |
|
|
validates :bike_style_id, :presence => true |
|
|
validates :bike_style_id, :presence => true |
|
|
validates :seat_tube_height, :presence => true |
|
|
validates :seat_tube_height, :presence => true |
|
@ -34,10 +33,6 @@ class Bike < ActiveRecord::Base |
|
|
self.bike_brand |
|
|
self.bike_brand |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def model |
|
|
|
|
|
self.bike_model |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def style |
|
|
def style |
|
|
self.bike_style |
|
|
self.bike_style |
|
|
end |
|
|
end |
|
|