In ActiveRecord, if I have something like: class Image has_many :image_tags has_many :tags, through: :image_tags end
class ImageTag belongs_to :image belongs_to :tag end class Tag has_many :image_tags has_many :images, through: :image_tags end It's possible for me to do something like this: Image.new(file: file, tag_ids: [1, 2, 3]) This creates a new image, and automatically makes the proper entries in the join table. A similar association in Sequel looks like: class Image many_to_many :tags, join_table: :image_tags end class ImageTag many_to_one :image many_to_one :tag end class Tag many_to_many :images, join_table: :image_tags end Is there any equivalent in Sequel for setting the association by the ids of the model to be associated? The docs mention the add_associated, remove_associated, and remove_all_associated methods, which could be combined to accomplish this use-case fairly simply. However, if there's some plugin or other method that accomplishes this already, I'd rather use that than roll my own. It also seems like you can't do something like this, either: Image.new(tags: Tag.all) I do notice that this raises Sequel::MassAssignmentRestriction, but the error says that the method "tags=" doesn't exist, so I'm not sure what's going on, exactly. Does Sequel have a way to set associations in this way? Thanks, Anthony -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
