Class_eval problem

class AssigneesController < ApplicationController

def assignees

@assinees = Assignee.find(:all, :select => “#{params[:assignee_clean_by]}, id”).uniq_by(&"#{params[:assignee_clean_by]}".to_sym)

Assignee.class_eval %Q{

def assignee_name

self["#{params[:assignee_clean_by]}"]

end

}

end

def do_assignee_cleaning

Assignee.find(1).assignee_name

redirect_to assignee_cleaning_project_assignees_path(params[:project_id])

end

end

in assignees.html.erb

@assignees.each do |assignee|

assignee.assignee_name

end

I am able to call assignee_name method on assignee object in assignees.html.erb.

But in do_assignee_cleaning action, i get error undefined method `assignee_name’ for #Assignee:0xc306ac why?

As Colin mentioned on the other thread, you will need to call assignees before you call do_assignee_cleaning, otherwise the assignee_name method wouldn’t be defined