mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-09-16 08:31:36 -04:00
Add bike routes, controller, and views. Update model.
This commit is contained in:
+25
-5
@@ -3,11 +3,11 @@ class Bike < ActiveRecord::Base
|
||||
:top_tube_length, :wheel_size, :value, :bike_condition_id, :bike_status_id
|
||||
|
||||
has_one :owner, :class_name => 'User'
|
||||
has_one :brand, :class_name => 'BikeBrand'
|
||||
has_one :model, :class_name => 'BikeModel'
|
||||
has_one :style, :class_name => 'BikeStyle'
|
||||
has_one :condition, :class_name => 'BikeCondition'
|
||||
has_one :status, :class_name => 'BikeStatus'
|
||||
belongs_to :bike_brand
|
||||
belongs_to :bike_model
|
||||
belongs_to :bike_style
|
||||
belongs_to :bike_condition
|
||||
belongs_to :bike_status
|
||||
|
||||
validates :serial_number, :uniqueness => true, :length => { :minimum => 3 }
|
||||
validates :bike_brand_id, :presence => true
|
||||
@@ -23,6 +23,26 @@ class Bike < ActiveRecord::Base
|
||||
|
||||
self.per_page = 15
|
||||
|
||||
def brand
|
||||
self.bike_brand
|
||||
end
|
||||
|
||||
def model
|
||||
self.bike_model
|
||||
end
|
||||
|
||||
def style
|
||||
self.bike_style
|
||||
end
|
||||
|
||||
def condition
|
||||
self.bike_condition
|
||||
end
|
||||
|
||||
def status
|
||||
self.bike_status
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#{brand} - #{model} - #{style}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user