Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6727755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:05:14+00:00 2026-05-26T10:05:14+00:00

There is probably a better way to accomplish this. I click on this button

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:05:14+00:00Added an answer on May 26, 2026 at 10:05 am

    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.

    - # monday
    = radio_button_tag 'days_gift_available', '1', true, {:class => "live-form"}
    - # tuesday 
    = radio_button_tag 'days_gift_available', '2', false, {:class => "live-form"}
    - # thursday
    = radio_button_tag 'days_gift_available', '3', false, {:class => "live-form"}
    - # ...until sunday
    

    in your controller:

    @organization.days_gift_available = params[:days_gift_available]
    

    params[:days_gift_available] is the selected day and should lie in the range from 1 to 7

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there is probably a better way of doing this, I have tried
Ok, there is probably a better way of doing this, and if this is
I've created a salt using; md5(rand(0,10000000)); (there is probably a better way?) There doesn't
I'm a total PHP newb, so there is probably a better way of outputting
I'm new with Objective-C, so there probably is a simple solution to this. I
There is probably is simple fix for this but I currently have code similar
i've spent some time searching and there is probably is an easy way to
There is probably an easy answer for this, just not sure how to tease
I have this script which calculates days until someone's next birthday (there's probably a
I still have a large number of floppies. On some of them there probably

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.