I have been working on this problem for two days and can’t seem to make
an progress on it. I am positive that I am just missing something
obvious. I am using attachment_fu, I have created an image model and
images controller, and everything is working fine. Now I want to have
the uploaded images associated with a project using a project_id column.
I want to do this from the show page for each project, grabbing the
project id from the params using a hidden field to pass to the model.
Here is what I put into the show.rhtml view, presented by the projects
controller:
<%= error_messages_for :image %>
<%= flash[:notice] %>
<% form_for(:image, :url => { :controller => ‘images’, :action =>
‘create’ }, :html => { :multipart => true }) do |f| -%>
Upload An Image: <%= f.file_field :uploaded_data %> <%= hidden_field 'project_id', params[:id] %>
<%= submit_tag 'Create' %>
<% end -%>When I submit that it does all the image stuff fine, but does not pass
the project id. When I look at the generated source the project id is
showing up in the form like this:
Upload An Image:
Am I losing the id in the redirect to the images controller? Can anybody
shed some light on the proper way to do this? I haven’t had any luck
searching around the web. Help is much appreciated!