Problem with hash

I’m opening a view and passing multiple key/value pairs within one
symbol like so:

<%= link_to ‘view’, {:controller => ‘screens’,
:action => “content”,
:data => {“title” => “Body”, “content” =>
screen.body}} %>

What’s the proper way to access these from the view I’m rendering? I
can access the params object to get at the info if I’m only passing one
value, but I’m having problems getting at both key/value pairs.

I’ve tried multiple variations of the following with no success:

<%= params[:data[“title”]] %>

Thanks,

On 11 Jan 2008, at 16:04, Corey M. wrote:

can access the params object to get at the info if I’m only passing
one
value, but I’m having problems getting at both key/value pairs.

I’ve tried multiple variations of the following with no success:

<%= params[:data[“title”]] %>

params[:data][:title]
(the params hash is magic so it doesn’t matter if you use strings or
keys)

Fred

Frederick C. wrote:

params[:data][:title]
(the params hash is magic so it doesn’t matter if you use strings or
keys)

Fred

Works perfectly. Thanks Fred.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs