Rails naming convention for Uppercase names
I've got a model class:
class QRCode < ActiveRecord::Base
has_many :properties
end
So rails needs a database table named 'qr_codes' and a foreign key called 'qr_code_id'. But as a relationship in my Property Model it needs another na开发者_如何学JAVAme:
class Property < ActiveRecord::Base
belongs_to :q_r_code
end
So if I want to create a Property object I' have to say ':q_r_code => qrcode' But active_record wants a qr_code property, because the column is called 'qr_code_id'
Do I understand something wrong or is this type of name impossible to map for Rails?
P.S.: I'm using Rails 3.0.3
belong_to accepts a :foreign_key
and :class_name
attribute.
精彩评论