There is probably a better way to accomplish this.
I click on this button of 7 different buttons ( each for each day of the week ) in a form..
= radio_button_tag 'days_gift_available', '{:monday => true}', true, {:class => "live-form"}
Then when the form is sent, I get this in my params..
"{:monday => true}"
And here’s where I’m confused.. I want to take this data and apply it like so :
This is supposed to be a dynamic var for the day.
|
|
V
if @organization.days_gift_available[:day] == false || @organization.days_gift_available[:day] == nil
@organization.days_gift_available = {:day => true}
else
@organization.days_gift_available = {:day => false}
end
notice my awful failing attempt at using the variable for the [:day] attribute. Not really sure how to apply that either..
My question is, how do I pull this hash data and apply it in an update_attribute call.
How radio buttons work:
All radio buttons of a certain group have the same name BUT different values. Only the value of the checked radio button gets submitted.
in your controller:
params[:days_gift_available]is the selected day and should lie in the range from 1 to 7