Easy question: need clarification of the form_for idiom

I’ve been trying wrap my head around one specific section of Recipe 57
in “Rails Recipes”. The recipe is for image upload and processing.

Iâ??m staring at:

<% form_for :image, @image, :url => {:action => â??createâ?? }, :html =>
{multipart => true } do | f | %>
â?¦
<% end %>

and the associated controller method â??createâ??:

def create
@image = Image.create params[ :image ]
end

Can someone please clarify for me what role :image and @image in both
the form and the method play?

Does :image correspond to the ID of the instance of the Image object
created in the calling controller?

It appears both :image and @image are unused in the form, what up?

Within the create method, is :image the ID of an image in the dbase?
Where was it set?

I would really appreciate clarification of this.

Thanks,
Doug

Hi. I’m a newbie myself, but I’ve had the same question. the form_for
tag was not used in the page that I was looking at (
Peak Obsession ). It was form_tag,
which explains why you didn’t see :image or @image.
In that example, the form returns a hash of the info you posted. The
“name” attribute in the input specifies the field that you want to
satisfy. It’s more apparant what you want to do if you use the helper
function
<%= file_field(:model, ‘image’) %>
This is replaced by html tags.

I’m still learning so I don’t know a whole lot, but this might help a
bit (I know it helped me)
Four Days On Rails: http://rails.homelinux.org/
and of course the docs.
Here is my own post that I asked about accessing fields in the form:
File is nil - Rails - Ruby-Forum

Douglass T. wrote:

I’ve been trying wrap my head around one specific section of Recipe 57
in “Rails Recipes”. The recipe is for image upload and processing.

Iâ??m staring at:

<% form_for :image, @image, :url => {:action => â??createâ?? }, :html =>
{multipart => true } do | f | %>
â?¦
<% end %>

and the associated controller method â??createâ??:

def create
@image = Image.create params[ :image ]
end

Can someone please clarify for me what role :image and @image in both
the form and the method play?

Does :image correspond to the ID of the instance of the Image object
created in the calling controller?

It appears both :image and @image are unused in the form, what up?

Within the create method, is :image the ID of an image in the dbase?
Where was it set?

I would really appreciate clarification of this.

Thanks,
Doug