Forum: Ruby on Rails Select box problems

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
063c002d53bd9fda8aff676cc4439cd4?d=identicon&s=25 Paul Odeon (paulodeon)
on 2006-01-21 14:40
Hi all,

I am trying to get a select box to choose the type of goal records to
display using the scope field. I keep getting a " NoMethodError in
Admin#list" on line 8 "undefined method `scope' for
{"scope"=>"Yearly"}:HashWithIndifferentAccess"

The code from list.rhtml is

<%= start_form_tag :action => 'list' %>
<p>View goals by scope:
<%
options = [["Select the Goal's Scope", ""]] + Goal::GOAL_SCOPES
%>
<%= select("goal", "scope", options) %>
  <%= submit_tag 'Go' %>
</p>
<%= end_form_tag %>

and the list method is

  def list
    log = Logger.new(STDERR)
    log.level = Logger::DEBUG
    #log.debug(params[:goal][:scope])

    @goal = params[:goal]
    if @goal != nil

       #@goals = Goal.find(1)
       @goals = Goal.find(:all, :conditions => ["scope = :scope",
@goal])
	#log.debug(@goal.scope)
    else
      @goal_pages, @goals = paginate :goals, :per_page => 10
    end
  end

The goal.rb is:

class Goal < ActiveRecord::Base
  validates_presence_of :goal
  validates_uniqueness_of :goal
  acts_as_tree :order => "goal"

  GOAL_SCOPES = [["Lifetime", "Lifetime"], ["This Year", "This Year"],
["This Quarter", "This Quarter"], ["This Month", "This Month"], ["This
Week", "This Week"]].freeze

end

It seems that this is just a simple problem, but I am very new to rails,
any help is much appreciated

Cheers

Paul
This topic is locked and can not be replied to.