Displaying 1 result from an estimated 1 matches for "update_tags".
Did you mean:
update_flags
2005 May 23
1
has_and_belongs_to_many dual insert error ?
...----------
create table pictures (
id int primary key auto_increment,
title varchar(80)
);
create table tags (
id int primary key auto_increment,
tag varchar(32)
);
Domain objects
--------------
class Picture < ActiveRecord::Base
has_and_belongs_to_many :tags
def update_tags(tags)
tags = tags.collect! {|name| name.downcase}
reject_invalid_tags(tags)
remove_deleted_tags(tags)
reject_existing_tags(tags)
add_tags_to_picture(tags)
end
protected
def reject_invalid_tags(tags)
tags.reject! { |name| name.nil? or...