Add bike routes, controller, and views. Update model.

This commit is contained in:
Jason Denney
2012-12-09 14:26:58 -05:00
parent 885caefaf7
commit d3c466761e
8 changed files with 211 additions and 5 deletions
+25 -5
View File
@@ -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