Forum: Ruby on Rails model helper location

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eea3feaacbe44706164289d068d94828?d=identicon&s=25 Peter Michaux (Guest)
on 2006-01-15 19:25
(Received via mailing list)
Hi,

I'm looking at the rails cookbook for uploading files[1]. At the
bottom of the page it says that the sanitize_filename functioin would
probably go in a helper or a library. I wonder where these files would
be or what they would be called. Pehaps there are some conventions I
need to know about?

Thanks,
Peter

[1] http://manuals.rubyonrails.com/read/chapter/78
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 Joe Van Dyk (Guest)
on 2006-01-15 19:34
(Received via mailing list)
On 1/15/06, Peter Michaux <petermichaux@gmail.com> wrote:
> Hi,
>
> I'm looking at the rails cookbook for uploading files[1]. At the
> bottom of the page it says that the sanitize_filename functioin would
> probably go in a helper or a library. I wonder where these files would
> be or what they would be called. Pehaps there are some conventions I
> need to know about?

Put them into lib.

i.e.
$ cat lib/helpers.rb
module MyHelpers
  # ...
end

$ cat config/environment.rb
# buncha stuff
require_dependency 'helpers'
Eea3feaacbe44706164289d068d94828?d=identicon&s=25 Peter Michaux (Guest)
on 2006-01-15 19:47
(Received via mailing list)
Thanks Joe. Editing files in the lib directory requires a reboot of
webrick?

Peter
C8a634a01a2c4508360874bff7fb1a7f?d=identicon&s=25 Kevin Olbrich (olbrich)
on 2006-01-15 19:55
I think the convention is to place them into helper files in the
app/helpers directory.

If you name them something like

'#{model}_helper' they will get included in the controller class and
views.

Generic helpers can go into the 'application_helper.rb' file.

This does not require a reboot of webrick.

_Kevin
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 Joe Van Dyk (Guest)
on 2006-01-17 02:16
(Received via mailing list)
On 1/15/06, Peter Michaux <petermichaux@gmail.com> wrote:
> Thanks Joe. Editing files in the lib directory requires a reboot of webrick?

Maybe.  I thought that if you include the libraries via
'require_dependency', webrick wouldn't need a reboot.  But I'm
probably wrong.
This topic is locked and can not be replied to.