...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
Jonathan Viney wrote:> 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
>>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>