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'' %>
<p><label for="user_pic"></label><br/>
<%= file_column_field "user", "pic" %></p>
<%= 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?
--
Posted via http://www.ruby-forum.com/.
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 Pablo 2006/6/27, Jasbur <jasbur@gmail.com>:> > 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'' %> > <p><label for="user_pic"></label><br/> > <%= file_column_field "user", "pic" %></p> > <%= 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? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Juan Pablo Re. blog: http://ururails.wordpress.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060627/d46fb397/attachment.html
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 Ross 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.
--
Posted via http://www.ruby-forum.com/.