1
0
mirror of https://github.com/fspc/BikeShed-1.git synced 2025-02-28 16:53:23 -05:00
BikeShed-1/app/models/transaction.rb
Jason Denney 2d51bd1d9a Creating Transactions works
-Need to scope transactions for users
-Only Admins should be able to create transactions
2013-01-20 16:14:53 -05:00

20 lines
624 B
Ruby

class Transaction < ActiveRecord::Base
acts_as_loggable
attr_accessible :vendor_id, :customer_id, :customer_type, :bike_id, :amount, :item
belongs_to :vendor, :class_name => 'User', :foreign_key => 'vendor_id'
belongs_to :bike
belongs_to :customer, :polymorphic => true
validates :vendor_id, :presence => true
validates :customer_id, :presence => { :message => "Choose a User or Customer"}
validates :customer_type, :presence => { :message => "Choose a User or Customer"}
validates :amount, :presence => true
validates :item, :presence => true
def to_s
"#{amount} #{item} #{bike_id}"
end
end