Zhao Yi wrote:
> I use form_tag like below:
> 
> <% form_tag (my_action) %>
> 
> <%= submit_tag "Submit" %>
> 
> <% end %>
> 
> In this case, how can I pass a Ruby object to "my_action" action? I want
> to pass a Hash to the next action.
> 
> thanks.

You can't pass ruby objects from the form to the controller because the 
browser has no concept of ruby or rails or any of that stuff.  However, 
you can build a hash to put into params like this

<%= hidden_field_tag "foo[bar]", "hello" %>

which creates this situation

params => {:foo => {:bar => "hello"}}

Knowing this, you can make a hidden field tag, or set of hidden field 
tags, which recreates the hash you want to pass through.  Ultimately, 
this is all that a form does:  it builds a data structure inside params, 
which is a hash that can contain other hashes, strings, and arrays.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to