To make a method in a controller a helper method, use the helper_method, as in:
helper_method :some_method
Here is the api page:
http://rails.rubyonrails.com/classes/ActionController/Helpers/ClassMethods.html#M000109
This will only make it available in a controller and view though.
Perhaps you should create a library and stick it in the lib directory
if it must be in both controllers and models.
Tom
On 10/12/05, Patrick McCafferty
<ryouga-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I want a method to be accessible from everywhere in my app (it''s a
Gaussian
> RNG) - I''ve already put them as protected methods in
application.rb but that
> would only allow them to be accessed from controllers.
>
> I have a method in a model that needs access to this too, and I''d
prefer
> not performing the calculations outside the model. Copying the method
> definition into the model violates DRY, but I don''t see any
"helper" files
> for models. Is there some place to put this, or am I stuck putting it in a
> module and requiring it everywhere? (require nexus_helpers?)
>
> Thanks.
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>