Martin
Martin

Reputation: 11336

How to separate values from a params hash in Rails

I have a form with this

check_box_tag "upgrade[#{user.id}]"

On next page, If i do

params[:upgrade]

I get 161 as value, but I would like only the id which is 16.

How can I separate only to get the first value?

When I do debug params[:upgrade] I get:

--- !map:ActiveSupport::HashWithIndifferentAccess 
    "16": "1"

Thank you!

Upvotes: 0

Views: 387

Answers (1)

dombesz
dombesz

Reputation: 7899

I guess you have to write like this:

check_box_tag "upgrade[]", user.id

For reference please see this railscast

Upvotes: 2

Related Questions