I have an active record class that looks like
class User < ApplicationRecord
has_many :audiobooks
has_many :ebooks
has_many :physicalbooks
end
I want to get/set the relations using the names. How can I do that?
A probable example of the operation I want to perform:
books = [ :audiobooks, :ebooks, physicalbooks]
books.each do |b|
user[b].build(...)
end
How can I do this in ActiveRecord.