Monday 15 February 2010

Updating avatar on Ruby on Rails with paperclip -


I have looked around and I did not know why this is working, I upload the avatar to the users for the first time Allow to sign up without the need to However, if they want, they can upload avatar after signing up. I allow them to edit their avatar in the "Profile" controller, not in user control. However, Avatar will not be updated. I am planning for users to code below

    

And in the user control, I have this:

  dig editing @username = user.fund (params [: id]) @user.update_dataite   

In the user's model, I have this

  ._tatched_file: Avatar, : Genres = & gt; {: Show = & gt; "150x150 #"} ,: default_url = & gt; 'Missing_: style.png'   

Avatar does not update or does not save I'm not sure why.

Update with new form code:

  form_for, for url = & gt; current_user {: Action = & gt; 'Updates'} ,: html = & gt; {: Multipurpose = & gt; True] do it Form | & Gt%; & Lt;% = form.file_field: avatar% & gt; & Lt;% = form.submit "Upload"% & gt; & Lt;% end% & gt;   

In the Profile Controller, I have this:

  def update = user = user.find (params [: id]) @ user.update_attribute ( : Avatar, params [: user] [: avatar]) end   

I get this error: the undefined method passed to `name 'request for #

The going parameters are below

  {"utf8" => "One", "_method" = & gt; "Put", "authentication_token" = & gt; "CxANtlyj + W + ykSnivfQTfTznkpt7yXe75E8jWI1IC + o =", "user" => {"Avatar" = & gt; # & Lt; Action Dispatch :: HTP :: Uploaded file: 0x000001032ac7c8 @boot_filename = "Pictator page", @Contact_type = "image / PNG", @header = "content-description: form-data; name = \" user [avatar] \ "; File name = \ "painter \" \ r \ ncontent-type: image / PNG \ r \ n ", @tempfile = # & lt ;;}" & gt; " Upload "," id "=> 1 "}        def update , not  def   

C.> This form is for presentation.

In profiles_controller.rb

  def update @user = User.find (params [: id]) @ User.update_attribute (: avatar, params [: user] [: avatar]) end   

should work.

No comments:

Post a Comment