Ruby on Rails
Wednesday, February 5, 2014
On Wednesday, February 5, 2014 4:46:12 PM UTC, Ruby-Forum.com User wrote:
According to this article Rails helpers from all controllers are
available to all views. But to me this looks kind of a dangerous
approach because I might at some point use helper methods with the same
name but with different implementations that can cause conflicts and
undesired results. This actually happened one time and it took me quite
some time to figure out the problem.
Why is the Rails helper scope this way?
What is the reason for sharing?
Does anyone had any problems with this approach?
Is there another recommended way to work?
http://strugglingwithruby.blogspot.com.br/2008/10/view- part-2-scope-helpers-and- partials.html
The reason is to encourage people to split out their helpers rather than just dumping everything in application_helper.rb (because with this you can do that without having to add lots of helper :blah lines to your controllers). Personally I think it's a really bad idea for the reason you mention and always set config.action_controller.include_all_helpers = false to stop this happening
It's also worth looking at gems just as draper - a lot of the helpers I used to write secretly wanted to be decorators
Fred
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/38ef6bdf-2aba-48fa-a2f4-15de39524e4c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment