form_for submit to a custom action

hi forum,

I am new to rails, and i am just getting my hang of things.

Problem,
how do you pass content captured in a form to a custom method?

I have the following form:

  <% form_for :message, @message, :url => { :action => 'reply'} do |f|
%>
  <table cellpadding="4" cellspacing="5">
    <tr>
         <td>Content:<%= f.text_area :body %></td>
    <tr>
        <td><%= submit_tag "Send" %></td>
    </tr>
  </table>
  <% end %>

this form is posting to a method called reply(), reply will need to take

the :body from the message, so the incoming request parameters look like
this:

{"message"=>{"body"=>"this is the reply"},
"commit"=>"Send",
"authenticity_token"=>"e2a058071a4037d85008f46b35818e160f5230ce"}

how do i retrieve "body"=>"this is the reply" from the request in the
reply action?

any tips are appreciated!

~zonman

You can use a book on Rails like the one from Pragmatic Programmers.
There are many nice features in the framework that need explanation
and you are missing out on what Rails has to offer by hack and slash
which constraints your thinking to the other frameworks you are used
to.

To answer your question, assuming the form is for the object of type
Message, you can do a xyz=Message.new(params[:message]) in your
controller and access the attribute normally.

In general, the params hash (method 'params') is always available to
your controller actions. You literally wrote how your params hash
looks like (your incoming request parameters), so it's just plain Ruby
code to retrieve the contents of the hash:
params[:message] returns the hash {'body' => 'this is the reply'}
so params[:message]['body'] would give you the string 'this is the
reply'

Beside checking a Rails book, I found that most useful is a good grasp
of Ruby itself (the 'pickaxe' book is a good start). You can learn
Rails pretty much on the go, but good Ruby skills are really valuable
to move on quickly.