On 21 June 2011 11:11, mukesh singh <mukesh23.si...@gmail.com> wrote:
> class AssigneesController < ApplicationController
>  def assignees
>     Assignee.class_eval %Q{
>                 def assignee_name
>                     self["#{params[:assignee_by]}"]
>                 end
>            }
>   end
>   def do_assignee_cleaning
>       Assignee.assignee_name
>       redirect_to
> assignee_cleaning_project_assignees_path(params[:project_id])
>   end
>
> end
> I want to use assignee_name method in do_assignee_cleaning action but i am
> getting  error undefined
> method `assignee_name' for class `Assignee' in do_assignee_cleaning

In an effort to understand the question (not having used class_eval) I
found the following link that suggests, rather non-intuitively, that
you should be using instance_eval rather than class_eval.

http://ilikestuffblog.com/2009/01/09/fun-with-rubys-instance_eval-and-class_eval/

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to