# Class\_eval problem

**URL:** <https://discuss.rubyonrails.org/t/class-eval-problem/59554>\
**Category:** rubyonrails-talk\
**Created:** [June 21, 2011, 11:41am UTC](https://discuss.rubyonrails.org/t/class-eval-problem/59554 "2011-06-21T11:41:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mukesh\_Singh](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@Mukesh\_Singh](https://discuss.rubyonrails.org/u/Mukesh_Singh)\
**Post date:** [June 21, 2011, 11:41am UTC](https://discuss.rubyonrails.org/t/class-eval-problem/59554/1 "2011-06-21T11:41:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Chirag](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@Chirag](https://discuss.rubyonrails.org/u/Chirag)\
**Post date:** [June 21, 2011, 12:01pm UTC](https://discuss.rubyonrails.org/t/class-eval-problem/59554/2 "2011-06-21T12:01:18Z")

</div>

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
