How does Active Record determine what tables to use when you define an
association? For example
class Order < ActiveRecord::Base
has_many :orderItems
end
class OrderItem < ActiveRecord::Base
belongs_to :order
end
Then in a view you use the association name:
@order[0].orderItems.each {|line| puts line.item_id + " - " +
line.name}
It turns out that you can also use the names "order_items" or
"Order_Items" instead of "orderItems" and that works fine.
I would
expect one or the other to work but not both.
Is ambiguity this by design?
Which should be used according to best practice?
Rick
--
Posted via http://www.ruby-forum.com/.
On Nov 19, 2005, at 10:22 AM, Rick wrote:> Is ambiguity this by design?Yes.> Which should be used according to best practice?Rubyists usually use CamlCase for ClassNames. Personally, I prefer :order_items for symbol names. But, the great thing is you get to use whatever you want! --Steve