Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

ruby - Why are all Rails helpers available to all views, all the time? Is there a way to disable this?

Why can I access helper methods for one controller in the views for a different controller? Is there a way to disable this without hacking/patching Rails?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

@George Schreiber's method doesn't work as of Rails 3.1; the code has changed significantly.

However, there's now an even better way to disable this feature in Rails 3.1 (and hopefully later). In your config/application.rb, add this line:

config.action_controller.include_all_helpers = false

This will prevent ApplicationController from loading all of the helpers.

(For anyone who is interested, here's the pull request where the feature was created.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...