# Rails 3 Upgrade

**URL:** <https://www.ruby-forum.com/t/rails-3-upgrade/191800>\
**Category:** Rails\
**Created:** [July 19, 2010, 2:34am UTC](https://www.ruby-forum.com/t/rails-3-upgrade/191800 "2010-07-19T02:34:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 19, 2010, 2:34am UTC](https://www.ruby-forum.com/t/rails-3-upgrade/191800/1 "2010-07-19T02:34:10Z")

</div>

I have a working 2.3.5 rails app that I am upgrading to rails 3 beta 4.  
I had monkey-patched a couple of class methods to the Activerecord::Base  
class and put it in the lib directory. This has worked fine for ages in  
2.3.x, but Rails 3 is refusing to even recognize it. I get undefined  
method error from my controller method. Here are the details:

NoMethodError in ClientsController#index

undefined method `my\_search’ for #Class:0x7f08d251dee8

Rails.root: /home/bruparel/rr\_work/file\_manager3  
Application Trace | Framework Trace | Full Trace

app/controllers/clients\_controller.rb:17:in `index’

Here is the line number 17 in the clients\_controller.rb file above:

```
  @clients = Client.my_search(params[:search], params[:page],

```

get\_search\_field, user\_role, perms)

As you can see, it calls my\_search method which I have defined in the  
Rails.root/lib/active\_record\_extensions.rb file as follows:

module ActiveRecord

class Base  
def self.my\_search(search, current\_page, search\_field, user\_role,  
perms)  
if search.blank?  
if user\_role == ‘staff’  
paginate(:all, :conditions =\> [“id in (?)”, perms], :page =\>  
current\_page || 1, :per\_page =\> 10)  
else  
paginate(:all, :page =\> current\_page || 1, :per\_page =\> 10)  
end  
else  
if user\_role == ‘staff’  
paginate(:all, :conditions =\> ["#{search\_field} LIKE ? and id  
in (?)", “%#{search}%”, perms],  
:order =\> search\_field, :page =\> current\_page || 1,  
:per\_page =\> 10)  
else  
paginate(:all, :conditions =\> ["#{search\_field} LIKE ?",  
“%#{search}%”], :order =\> search\_field,  
:page =\> current\_page || 1, :per\_page =\> 10)  
end  
end  
end  
end

I don’t understand why does Rails refuse to find it. I looked up the  
Rails 3 documenation, as far as I can tell, the organization of  
ActiveRecord module and the Base class has not changed. Why is this  
then happening?

Thanks.

Bharat

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [July 19, 2010, 3:23am UTC](https://www.ruby-forum.com/t/rails-3-upgrade/191800/2 "2010-07-19T03:23:06Z")

</div>

Apologies. Please ignore. I had forgotten to include my initializer to  
load files from the library path.  
Thanks.  
Bharat
