On 19 February 2011 09:12, Colin Law <[email protected]> wrote: >> So I put in my model: >> >> self = other_upload if other_upload = >> Upload.find_by_upload_file_name(self[:upload_file_name]) >> >> which ActiveRecord doesn't let me do saying "Can't change the value of >> self" > > That is not an ActiveRecord issue it is a basic Ruby issue. Once you > are inside an instance method I do not think there is any way of > suddenly deciding you want to be in the method of a different object.
+1 The functionality you're interested in should be called from the controller. # pseudo-Ruby upload = Upload.new(params[:upload]) if Upload.find_by_file_name(upload.file_name) upload = Upload.find_by_file_name(upload.file_name) end You can't change "self" to "be" a different instance, but you can overwrite a variable containing one instance, with another instance. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

