Reputation: 3637
Override Rails controller routing with capital letters in model name
I followed that question and answer, but it did not help me.
I need to create a model from an already existing table, BBOrders.
What is .rb file, class name, how would I access it in the console and do I have to add anything inside the class.
Right now what I have is
b_b_order.rb
class BBOrder < ActiveRecord::Base
set_table_name "BBorders"
set_primary_key "orderID"
end
and when I call the BBOrder.all in the console, I get the unitialized constant BBOrder.
Upvotes: 1
Views: 988
Reputation: 5721
'BBOrder'.underscore #=> 'bb_order'
This means your file should be named bb_order.rb
Inside of your class you need to change set_table_name
and set_primary_key
to the following:
bb_order.rb
class BBOrder < ActiveRecord::Base
self.table_name = "BBorders"
self.primary_key = "orderID"
end
Upvotes: 3