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

  • Home
  • SEARCH
  • 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 6593971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:45:03+00:00 2026-05-25T17:45:03+00:00

My form has: <%= f.select(:amount, Payment::AMOUNT_VALUES, {:blank => false}) %> My model has: AMOUNT_VALUES

  • 0

My form has:

<%= f.select(:amount, Payment::AMOUNT_VALUES, {:blank => false}) %>

My model has:

AMOUNT_VALUES = { '$ 0' => 0, '$ 1' => 1, '$ 2' => 2, '$ 5' => 5, '$ 10' => 10 }.

If user select $2 and submits form. The next time he goes back to the form, I need it only to display everything above $2 in the select box. Therefore, the options should be $5 and $10 only.

How can this be achieved?

  • 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-25T17:45:04+00:00Added an answer on May 25, 2026 at 5:45 pm

    I recently wrote some helper code that helped me rule out days of the week where a store had already posted business hours for. It shouldn’t be too hard to adapt to your specifications.

    Updated: Added question-specific code and updated with a more-efficient reject block.

    module HoursHelper
      ...
      def generateDayStrings (unavailable_days)
        all_days = [ ['Sunday',    'Sun'], 
                     ['Monday',    'Mon'],
                     ['Tuesday',   'Tue'],
                     ['Wednesday', 'Wed'],
                     ['Thursday',  'Thu'],
                     ['Friday',    'Fri'],
                     ['Saturday',  'Sat'] ]
        all_days.reject do |day|
          (day - unavailable_days).size != 2
        end
      end
      ...
    end
    
    <%= f.select :day_of_week, generateDayStrings(@days_with_hours) %>
    
    # @days_with_hours = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']
    # generateDayStrings(@days_with_hours) = [ ['Sunday', 'Sun'], ['Saturday', 'Sat'] ]
    

    For your particular codebase, it’d probably look something like this:

    module PaymentsHelper
      ...
      def generatePaymentAmountSelectArray (unavailable_denoms)
        all_denoms = [ ['$ 0',  '0'], 
                       ['$ 1',  '1'],
                       ['$ 2',  '2'],
                       ['$ 5',  '5'],
                       ['$ 10', '10'] ]
    
        # or all_denoms = Payment::AMOUNT_VALUES
        # although not sure how this works with a hash.
    
        all_denoms.reject do |current_denom|
          (current_denom - unavailable_denoms).size != 2
        end
      end
      ...
    end
    
    <%= f.select :amount, generatePaymentAmountSelectArray(@used_values), {:blank => false}) %>
    
    # just make sure you set @used_values in your controller
    

    I feel like there’s a better way of doing this, so I’ll update if I remember it.

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

Sidebar

Related Questions

My form has the following: <%= f.select(:amount, Order::AMOUNT_VALUES, {:blank => false}) %> My model
i have a form that has a multiple select drop down. a user can
I have a rails form where user has to select a value from a
I have written a simple CRUD form which has one select list. However the
My form has a custom element like below, created using custom ajax: <select jwcid=testtest
My simple donation form submits properly except for Internet Explorer. I'm sure it has
I have a form that has multiple select drop downs. i.e. Item 1: <select
i have a form that has select element <select name=adddisplaypage[] id=adddisplaypage multiple=multiple> <option value=all
I have a form that has two select lists: <select name=rating1 id=rating1> <option>1</option> <option>2</option>
I have a form that has select inputs as well as checkboxes. The following

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.