How do I check the retuned value from check_box_tag?

Hi,

I have this in my form

<%= check_box_tag(@accept, value = “1”, checked = false) %>

Which puts a nice checkbox on my form but when I try to retrieve the
value that is returned, which I expect to find in @accept, there is
nothing. How do I check the returned value?

Thanks,

Paul Thompson

I have this in my form

<%= check_box_tag(@accept, value = “1”, checked = false) %>

Which puts a nice checkbox on my form but when I try to retrieve the
value that is returned, which I expect to find in @accept, there is
nothing. How do I check the returned value?

The docs say:

check_box_tag(name, value = “1”, checked = false, options = {})

I think what you want is:

<%= check_box_tag(‘accept’, value = “1”, checked = false) %>

and then you’ll find the value in params[:accept].

Or you want check_box, which takes and object and a method… see the
docs…

-philip

The api entry looks like this…

check_box_tag(name, value = “1”, checked = false, options = {})

You want a name like “accept” rather than “@accept

and you would access it with params[:accept]

Thanks Philip, it works just fine now. I must admit that as new to OOP
rails and Ruby, I find the documentation somewhat obscure.

Regards,

Paul

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