[Rails] access to application.rb methods

Jonathan Viney
2006-06-21T05:20:14Z

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.

On 6/21/06, thila thila <isputnik_98@yahoo.com>
wrote:
> 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
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>