Not able to override helper

I’m trying to upgrade an application to Rails 3 and I found a difference
in the way helpers are loaded. I want to override a method based on
the current controller but it now seems that all helpers are loaded.

I’ve broken it down to a simple example. I have a test app with 2
controllers - books and authors. In the BooksHelper module, I have:

module BooksHelper
def some_helper
“From books helper”
end
end

In AuthorsHelper module, I have:

module AuthorsHelper
def some_helper
“From authors helper”
end
end

In my index.html.erb for Books I include <%= some_helper %>
and in index.html.erb for Authors I include the same <%= some_helper %>.

When I do the books index it shows as “From books helper” but when I do
a authors index I get the same “From books helper” - I had hoped for
“From authors helper”. I tried the same app in rails 2 and I get the
helper method from the current controller used - so I get what I
expected.

In my real app - I have a call in the layouts - application.html.erb
where I call the helper and hope to get the current controller’s helper
so I can show information (like bread crumbs) for the current
controller.

That’s because Rails 3 implies helper :all.

https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5348-visibility-of-helpers-seems-all-wrong

On Mon, Oct 18, 2010 at 11:57 PM, Christopher G.
[email protected]wrote:

end
In my index.html.erb for Books I include <%= some_helper %>
so I can show information (like bread crumbs) for the current

[email protected][email protected]

.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Erol M. Fornoles
http://erolfornoles.posterous.com
http://github.com/Erol
http://twitter.com/erolfornoles
http://ph.linkedin.com/in/erolfornoles

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