File Column has me stumped

I have an existing entry in my DB under the “users” table that has a
column name “pic”. I have a file column field when a new user signs up,
and it work great. I am now trying to give existing users the ability to
add or change their “pic”. But, no matter what I do the entry comes up
blank. Here’s what I have so far:

View:
<%= start_form_tag ({:action => ‘settings_save’, :id => @user.id},
:multipart => true) %>
<%= error_messages_for ‘user’ %>


<%= file_column_field "user", "pic" %>

<%= submit_tag "Change" %> <%= end_form_tag %>

controller:
def settings_save
@user = User.find(params[:id])
@user.update_attribute(“pic”, params[:pic])
end

In the log:
Parameters: {“user”=>{“pic_temp”=>"", “pic”=>#<File:/tmp/CGI11901.1>},
“commit”=>“Change”, “action”=>“settings_save”, “id”=>“9”,
“controller”=>“account”}

It seems the variable is not being passed correctly. Any ideas?

first, sorry my english…

I think that you must upload the new image, there single you change the
path
but in the folder nothing is modified and been original the greetings

Juan P.

2006/6/27, Jasbur [email protected]:

It appears that in your controller, you want to do:

@user.update_attribute(“pic”, params[:user][‘pic’]

Because ‘pic’ is part of the ‘user’ hash. Right?

View this message in context:
http://www.nabble.com/File-Column-has-me-stumped-tf1856921.html#a5071442
Sent from the RubyOnRails Users forum at Nabble.com.

Steve, you’re my new hero! That was it. I was calling a param that
didn’t exist. Just in case someone searches for this later you forgot
the last ‘)’ in the code you gave. The final ine is:

@user.update_attribute(“pic”, params[:user][‘pic’])

Thanks again.

Steve R. wrote:

It appears that in your controller, you want to do:

@user.update_attribute(“pic”, params[:user][‘pic’]

Because ‘pic’ is part of the ‘user’ hash. Right?

View this message in context:
http://www.nabble.com/File-Column-has-me-stumped-tf1856921.html#a5071442
Sent from the RubyOnRails Users forum at Nabble.com.

Missing paren. Serves me right for typing before thinking :-

View this message in context:
http://www.nabble.com/File-Column-has-me-stumped-tf1856921.html#a5071782
Sent from the RubyOnRails Users forum at Nabble.com.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs