# Access to application.rb methods

**URL:** <https://www.ruby-forum.com/t/access-to-application-rb-methods/64002>\
**Category:** Rails\
**Created:** [June 21, 2006, 7:15am UTC](https://www.ruby-forum.com/t/access-to-application-rb-methods/64002 "2006-06-21T07:15:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thila](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@thila](https://www.ruby-forum.com/u/thila)\
**Post date:** [June 21, 2006, 7:15am UTC](https://www.ruby-forum.com/t/access-to-application-rb-methods/64002/1 "2006-06-21T07:15:04Z")

</div>

Why can’t I access the utility methods defined in applicaion.rb from the  
model classes? If that does not work, where is the best place to put  
common utility methods that must be available to all the models.

thanks

---

<div class="post-metadata">

**Author:** ![thila](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@thila](https://www.ruby-forum.com/u/thila)\
**Post date:** [June 21, 2006, 7:21am UTC](https://www.ruby-forum.com/t/access-to-application-rb-methods/64002/2 "2006-06-21T07:21:12Z")

</div>

If you want some more instance methods on all your models, just add  
them to ActiveRecord::Base in environment.rb

class ActiveRecord::Base  
def my\_method  
“hello”  
end  
end

Then your models behave like…

class Person \< ActiveRecord::Base  
end

Person.new.my\_method # =\> hello

-Jonathan.

---

<div class="post-metadata">

**Author:** ![thila](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@thila](https://www.ruby-forum.com/u/thila)\
**Post date:** [June 21, 2006, 2:08pm UTC](https://www.ruby-forum.com/t/access-to-application-rb-methods/64002/3 "2006-06-21T14:08:16Z")

</div>

…or add them to a module which you include in the model.  
application.rb is a controller (indeed _the_ ApplicationController from  
which the other controllers inherit methods, filters etc), and therefore  
methods and filters defined in it shouldn’t be accessible to the models.  
MVC and all that…  
HTH
