Find the right object

isn't there a "find_or_create" function? otherwise maybe adding your own custom find_or_create method to the settings model would be a cleaner solution.

Jonas wrote:

you add it to the model as a class method, so you don't need an object to call it on. Then you can call it with Setting.find_or_create(@session['user'], params[:id]) . so in your model class you'd have something like:

self.find_or_create(user_id, image_id)     ret = Setting.find(:first, :conditions => ["user_id = ? and image_id = ?",user_id, image_id])     ret = Setting.create({:user_id => user_id, :image_id => image_id}) if !ret     ret end

Then you'd always get back a valid object.       Jonas wrote: