Model helper location

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

On 1/15/06, Peter M. [email protected] 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’

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

Peter

On 1/15/06, Peter M. [email protected] 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.

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs