1
0
mirror of https://github.com/fspc/BikeShed-1.git synced 2025-02-28 16:53:23 -05:00
Jason Denney 11e738b428 Adding transactions
-Need to create a customers table to store contact information of customers who are not a user.
-Need to scope "User Transactions" for users, staff, and admin. Need to have a "All Shop Transactions" tab.
-Need to add conditional UX to form.
2013-01-19 15:59:47 -05:00

53 lines
1.2 KiB
Ruby

class Bike < ActiveRecord::Base
acts_as_loggable
attr_accessible :serial_number, :bike_brand_id, :bike_model_id, :color, :bike_style_id, :seat_tube_height,
:top_tube_length, :wheel_size, :value, :bike_condition_id, :bike_status_id
has_many :transactions
has_one :owner, :class_name => 'User'
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
validates :bike_model_id, :presence => true
validates :color, :presence => true
validates :bike_style_id, :presence => true
validates :seat_tube_height, :presence => true
validates :top_tube_length, :presence => true
validates :wheel_size, :presence => true
#validates :value, :presence => true
validates :bike_condition_id, :presence => true
validates :bike_status_id, :presence => true
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
end