I'm just wondering if the association can be "renamed" in Rails. Let's pretend that
class SomeModelASubModel < ActiveRecord::Base
has_many :some_model_a_sub_model_items
end
class SomeModelASubModelItem < ActiveRecord::Base
belongs_to :some_model_a_sub_model
end
At this point, calling some_model.items, where some_model is an instance of the SomeModelASubModel class, will cause an undefined method error.
What is the best practice for this though, for example,
some_model = SomeModelASubModel.first
items = some_model.items
items = some_model.some_model_a_sub_model_items
Is such a reduction possible?
Thank you in advance!
Dr1ku source
share