checking for duplicates, if duplicate, concate duplicate...

Here's the break down.

2 models: song, artist

artists has many songs.

Is there already a pre-built method in rails that can check for duplicate artists, and if the artist already exists, it will add the song object instead of creating a new artist?

If there isn't I can write the method, would you write this in the model or the controller?

Basically it would do this.

grabs the artist[:name] params, do a find_by_name, if it finds it, then it will do concate with the song object, otherwise, it would create a new artist id.

Feng Tien,

   > grabs the artist[:name] params, do a find_by_name, if it finds it, then    > ..., otherwise, it would create a new artist id.

try :   a = Artist.find_or_create_by_name(params[:name])

Alain