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