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
[email protected] 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
James B. wrote:
In a Controller:
params[:myhash] => { :aa => ‘hashaa’, :bb => ‘hashbb’ }
That should be:
params[:myhash] = { :aa => ‘hashaa’, :bb => ‘hashbb’ }