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’ %>
View goals by scope: <% options = [["Select the Goal's Scope", ""]] + Goal::GOAL_SCOPES %> <%= select("goal", "scope", options) %> <%= submit_tag 'Go' %>
<%= 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