I assume you're replying to my post... but because you cut everything,
I don't know for sure...

On 19 February 2011 17:36, Shea Barton <[email protected]> wrote:
> I know I have to do it in the controller is just wish there was some way
> I could put it into the model that way I never have to worry about it in
> my "skinny controller".

find_or_initialize_by_?

Although, if you're doing some fudging with MD5 hashes, you may not be
able to use the dynamic methods....

# upload.rb
def self.find_or_initialize_by_params(params)
  upload = Upload.new(params)
  return Upload.find_by_upload_file_name(upload.upload_file_name) || upload
end

#controller
upload = Upload.find_or_initialize_by_params(params)

-- 
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.

Reply via email to