Hi,

Im currently working on an issue im having with a ruby method within my
rails project.

i have this method:

    def saveAssetTags(asset, taglist)
     #add new tags

     tagList = taglist.split(/\s*\,\s*/)
     #drop all current tags
     asset.tags.clear
     for metadata in tagList
       tag = Tag.find_by_Tag(metadata)
       unless tag
         tag = Tag.new
         tag.Tag = metadata
         tag.save
       end
       asset.tags << tag
     end

  end

its taking in a list of tags from the client seperated by comma's and
putting them into an array before saving them in my database. this all
works fine unless a user enters the same tag twice in which case i get a
duplication error in the db.

whats the best way to check the array for repeating attributes or to
check as i iterate through the loop?

Cheers,

Chris
-- 
Posted via http://www.ruby-forum.com/.