Hi I am working on one application which has so many relations on the model.
Now I am thinking to reduce line of code and I find so many relations like has_many and belongs_to.
Can we have singe line where we can write something like
belongs_to [:comment, :rating, :indication], dependent: :destroy
belongs_to :travels, foreign_key: travel_item_id
Unfortunately, not. AFAIK this is not possible and even the documentation doesn't seems to allow this. What you can do, is to define a metaprogramming method that iterate over an array and create this associations. But not sure if it worth it.
EDIT
Just an example of what I mean by
metaprogramming methodCreate a fileapp/models/concerns/associate.rbThen, in your model, to do the multiple
belongs_to, just do