goobelz-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org
2008-Apr-09 18:24 UTC
Howto pass hashes in params?
Hello,
i try to pass a hash in params.
h = Hash.new
[...]
<%= link_to ''next'',:url => {:controller =>
''myController'', :action =>
''myAction'', :h => h} %>
The myController-controller:
def myController
@h = params[:h]
end
But it doesn''t work like this. Can someone give me a solution. Is it
even possible to pass hashes in params?
regards
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
goobelz-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org wrote:> Hello, > > i try to pass a hash in params. > > h = Hash.new > > [...] > > <%= link_to ''next'',:url => {:controller => ''myController'', :action => > ''myAction'', :h => h} %> > > > The myController-controller: > > def myController > @h = params[:h] > end > > But it doesn''t work like this. Can someone give me a solution. Is it > even possible to pass hashes in params? >Try this: In a Controller: params[:myhash] => { :aa => ''hashaa'', :bb => ''hashbb'' } OR In a view: <% @myhash = { :aa => ''hashaa'', :bb => ''hashbb'' } -%> <%= link_to ''next'', :controller => ''myController'', :action => ''myAction'', :mykey => @myhash %> Gives --- !map:HashWithIndifferentAccess action: new controller: entities mykey: !map:HashWithIndifferentAccess aa: hashaa bb: hashbb -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
James Byrne wrote:> In a Controller: > > params[:myhash] => { :aa => ''hashaa'', :bb => ''hashbb'' } >That should be: params[:myhash] = { :aa => ''hashaa'', :bb => ''hashbb'' } -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---