Seymor
Seymor

Reputation: 13

How to access custom subdirectories in helpers (ruby on rails)?

Ruby on Rails: Is there any way to access subdirectories in helpers directory?

I mean:

/app/helpers/"subdir"/"foo.rb"

So I'd like to access methods and constants in foo.rb...

Upvotes: 1

Views: 1479

Answers (1)

Substantial
Substantial

Reputation: 6682

Rails includes all helpers by default, including those in subdirectories.

If your configuration requires controllers to include their own helpers, placing this in a controller:

helper "subdir/foo"

will include /app/helpers/subdir/foo_helper.rb, whose methods will be available to that controller's views.

Upvotes: 4

Related Questions