diff --git a/app/components/bikes.rb b/app/components/bikes.rb index 8591975..29ec030 100644 --- a/app/components/bikes.rb +++ b/app/components/bikes.rb @@ -4,6 +4,7 @@ class Bikes < Netzke::Basepack::Grid c.model = "Bike" c.columns = [ + { :name => :shop_id, :text => 'Shop ID'}, :serial_number, { :name => :bike_brand__brand, :text => 'Brand' }, { :name => :bike_model__model, :text => 'Model', diff --git a/app/components/transactions.rb b/app/components/transactions.rb index 4fe60bd..652c7fb 100644 --- a/app/components/transactions.rb +++ b/app/components/transactions.rb @@ -10,7 +10,7 @@ class Transactions < Netzke::Basepack::Grid c.columns = [ :amount, :item, - { :name => :bike__serial_number}, + { :name => :bike__shop_id}, { :name => :vendor, :getter => lambda { |rec| user = rec.vendor user.nil? ? "" : "#{user.first_name} #{user.last_name}" @@ -27,7 +27,7 @@ class Transactions < Netzke::Basepack::Grid end def default_fields_for_forms - bike_store = Bike.all.map { |b| [b.id, b.serial_number] } + bike_store = Bike.all.map { |b| [b.id, b.shop_id] } user_store = User.all.map { |u| [u.id, u.to_s] } customer = nil if session[:selected_customer_type] == "User" diff --git a/app/components/user_logs.rb b/app/components/user_logs.rb index ee0aebd..b001b42 100644 --- a/app/components/user_logs.rb +++ b/app/components/user_logs.rb @@ -50,7 +50,7 @@ class UserLogs < Netzke::Basepack::Grid def default_fields_for_forms #figure out a better way to do this - bike_store = Bike.all.map { |b| [b.id, b.serial_number] } + bike_store = Bike.all.map { |b| [b.id, b.shop_id] } current_user ||= User.find_by_id(session[:selected_user_id]) || controller.current_user bike_id = current_user.bike.nil? ? nil : current_user.bike.id action_id = current_user.user_role.id diff --git a/app/components/user_stats.rb b/app/components/user_stats.rb index 3a82704..cc52fa2 100644 --- a/app/components/user_stats.rb +++ b/app/components/user_stats.rb @@ -6,7 +6,7 @@ class UserStats < Netzke::Base

Total Hours Worked: #{user.total_hours}

Hours worked in #{Time.now.strftime('%B')}: #{user.current_month_hours}

-

Current bike ID: #{bike.id if bike}

+

Current bike Shop ID: #{bike.shop_id if bike}

Current bike S/N: #{bike.serial_number if bike}

) diff --git a/app/components/user_transactions.rb b/app/components/user_transactions.rb index 78688a3..9c0fdee 100644 --- a/app/components/user_transactions.rb +++ b/app/components/user_transactions.rb @@ -10,7 +10,7 @@ class UserTransactions < Netzke::Basepack::Grid c.columns = [ :amount, :item, - { :name => :bike__serial_number}, + { :name => :bike__shop_id}, { :name => :vendor, :getter => lambda { |rec| user = rec.vendor user.nil? ? "" : "#{user.first_name} #{user.last_name}" diff --git a/app/components/users.rb b/app/components/users.rb index 5934bd2..b844e4a 100644 --- a/app/components/users.rb +++ b/app/components/users.rb @@ -10,7 +10,7 @@ class Users < Netzke::Basepack::Grid :nickname, :email, :user_role__role, - :bike__serial_number + :bike__shop_id ] end diff --git a/app/models/bike.rb b/app/models/bike.rb index 67de6cb..600c516 100644 --- a/app/models/bike.rb +++ b/app/models/bike.rb @@ -1,6 +1,6 @@ class Bike < ActiveRecord::Base acts_as_loggable - attr_accessible :serial_number, :bike_brand_id, :bike_model_id, :color, :bike_style_id, :seat_tube_height, + attr_accessible :shop_id, :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 @@ -13,6 +13,7 @@ class Bike < ActiveRecord::Base belongs_to :bike_condition belongs_to :bike_status + validates :shop_id, :presence => true, :uniqueness => true, :length => { :minimum => 3 } validates :serial_number, :uniqueness => true, :length => { :minimum => 3 } validates :bike_brand_id, :presence => true validates :bike_model_id, :presence => true diff --git a/db/schema.rb b/db/schema.rb index 8baa56c..abb82cf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130209023110) do +ActiveRecord::Schema.define(:version => 20130405012238) do create_table "bike_actions", :force => true do |t| t.string "action", :limit => 128, :null => false @@ -60,9 +60,10 @@ ActiveRecord::Schema.define(:version => 20130209023110) do t.integer "bike_status_id", :null => false t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.string "shop_id" end - add_index "bikes", ["serial_number"], :name => "index_bikes_on_serial_number", :unique => true + add_index "bikes", ["shop_id"], :name => "index_bikes_on_shop_id", :unique => true create_table "customers", :force => true do |t| t.string "first_name", :null => false diff --git a/spec/factories/bikes.rb b/spec/factories/bikes.rb index 9e65460..ffe34e4 100644 --- a/spec/factories/bikes.rb +++ b/spec/factories/bikes.rb @@ -2,6 +2,9 @@ FactoryGirl.define do factory :bike do + sequence :shop_id do |n| + "Shop ID #{n}" + end sequence :serial_number do |n| "S/N# #{n}" end