Newbie question:
I have a template which has the following form....
<%= start_form_tag( {:action => ''create_image''},
:multipart => true) %>
<%= hidden_field ''cell'', ''id'' %>
<p><label
for="image_description">Description</label><br /><%=
text_field ''image'', ''description''
%></p>
<input type="file" id="image_file"
name="image[file]"/><br />
<input type="submit" value="create_image" />
<%= end_form_tag %>
<!--[eoform:content]-->
I have a controller called "cells_controller.rb", which contains the
following action:
def create_image
cell = Cell.find(@params[''cell[id]''])
# THIS WORKS! cell = Cell.find(2)
end
When I hit the button on the form I get the following error (the line #
corresponds to the Cell.find call in the controller):
Couldn''t find Cell without an ID
app/controllers/cells_controller.rb:58:in `create_image''
The Request has....
Parameters: {"cell"=>{"id"=>"2"},
"image"=>{"description"=>"asdfadsfasdf",
"file"=>#<StringIO:0x880f100>}}
Can anyone explain what''s wrong here? When I hard-code the id directly
it works fine. When I try to reference it via
@params[''cell[id]''] I get the error. The request seems to have
the value "2" there.
More generally... can anyone direct me to docs explaining the details of
how/what values are passed from a form to a controller, and how the controller
can reference them? Is this simple Ruby knowledge (that I don''t
have - sorry)?
Dan
Dan Sperka
Center for Neuroscience
UC Davis
djsperka_at_ucdavis_dot_edu