Fix validations for creating a bike, view respond to errors

This commit is contained in:
Jason Denney
2014-02-09 18:23:35 -05:00
parent 55974feb4c
commit d0c05a0244
3 changed files with 37 additions and 29 deletions
+6 -6
View File
@@ -16,13 +16,13 @@ class Bike < ActiveRecord::Base
validates :shop_id, :presence => true, :uniqueness => true, :numericality => { :only_integer => true }
validates :serial_number, :length => { :minimum => 3 }
validates :model, :length => { :maximum => 50 }
validates :bike_brand_id, :presence => true
validates :bike_brand_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid brand" }
#validates :color, :presence => true
validates :bike_style_id, :presence => true
validates :seat_tube_height, :presence => true
validates :bike_wheel_size_id, :presence => true
validates :bike_condition_id, :presence => true
validates :bike_purpose_id, :presence => true
validates :bike_style_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid style" }
validates :seat_tube_height, :presence => true, :numericality => true
validates :bike_wheel_size_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid wheel size" }
validates :bike_condition_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid condition" }
validates :bike_purpose_id, :presence => true, :numericality => { greater_than: 0, message: "is not a valid purpose" }
self.per_page = 15