This seems like it should be so simple, but I am just not getting it!

My

   @photo = Photo.find_by_project_id(params[:photo => :project_id])
                              (also have tried (params[:photo]
[:project_id]

in PhotosController statement always evalutates to nil,

   if @photo != nil
        @photo.update_attributes(params[:photo])

even though the project_id is in the params hash:
   (output from my application log:)

 Parameters: {"photo"=>{"project_id"=>"371", "user_id"=>"14",
"lwrimg"=>#<File:/tmp/RackMultipart.26504.0>}, "page_path"=>"projects/
edit", "authenticity_token"=>"iiwoOHgAaBTCv/U4xhmvlR2qleLbG
+Ov70cubJ7G8jQ=", "after_submit"=>"stay-here"}

...so the project_id is set.

However, the SQL query is:

    [4;35;1mPhoto Load (0.2ms)[0m   [0mSELECT * FROM `photos` WHERE
(`photos`.`project_id` IS NULL) LIMIT 1[0m

...which seems to indicate that (params[:photo => :project_id]) is
returning NULL,
or that I am misunderstanding

@photo = Photo.find_by_project_id(params[:photo => :project_id])

I thought the above would be that @photo is a copy of the record found
in the d.b., and
thus I would be able to use the test:

 if @photo != nil

So, what is the correct way to update a record if it exists?


Cheers,
   Jet



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to