1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Select_tag

Discussion in 'Ruby' started by robzdc, Apr 7, 2013.

  1. #1
    I cant find the issue here.

    #helpers/search_helper.rb
    def range1
        @range = []
        (10000..1000000).step(10000).each {|x|
          @range << ["value" => x, "name" => x]
        }
        return @range
    end
    Code (markup):
    #views/search/index.html.erb
    <%= select_tag "state", options_from_collection_for_select(range1, "value","name"), :prompt => "Select State" %>
    Code (markup):
    I got an
    undefined method `value' for [{"value"=>10000, "name"=>10000}]:Array
     
    robzdc, Apr 7, 2013 IP
  2. robzdc

    robzdc Greenhorn

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    11
    #2
    Done.
    I just change the helper to
    @range << [number_to_currency(x,:unit => "$"), x]
    Code (markup):
    and the view to
    select_tag "state", options_for_select(range1), :prompt => "From"
    Code (markup):
     
    robzdc, Apr 7, 2013 IP