search for: add_by_names

Displaying 1 result from an estimated 1 matches for "add_by_names".

2006 Feb 26
5
Help On Associations Extension.
...tom add method to the association. i have a table locations that has a many-to-many association with a tags tabel using a locations_tags table. i want to add a method to the Location has_and_belongs_to_many association so that i can do something like this on the location model: myLocation.tags.add_by_names ''tag1 tag2 tag3'' On the extension i want to do something like this: class Location < ActiveRecord::Base has_and_belongs_to_many :tags do def add_by_names tag_names tag_names.split(" ").each do |tag_name| tag = Tag.find_by_name(tag_name) || Tag.cr...