Model helper location


#1

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


#2

On 1/15/06, Peter M. removed_email_address@domain.invalid 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’


#3

Thanks Joe. Editing files in the lib directory requires a reboot of
webrick?

Peter


#4

On 1/15/06, Peter M. removed_email_address@domain.invalid 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.


#5

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