mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
remove AV.prepare and move all helper-related logic into the controller. this decouples the view since it no longer knows about routes internals.
this is a result of an ongoing discussion at https://github.com/rails/rails/pull/6826.
This commit is contained in:
parent
809bdf3426
commit
1b01ab4959
2 changed files with 13 additions and 19 deletions
|
@ -49,9 +49,19 @@ module AbstractController
|
|||
module ClassMethods
|
||||
def view_context_class
|
||||
@view_context_class ||= begin
|
||||
routes = _routes if respond_to?(:_routes)
|
||||
helpers = _helpers if respond_to?(:_helpers)
|
||||
ActionView::Base.prepare(routes, helpers)
|
||||
routes = respond_to?(:_routes) && _routes
|
||||
helpers = respond_to?(:_helpers) && _helpers
|
||||
|
||||
Class.new(ActionView::Base) do
|
||||
if routes
|
||||
include routes.url_helpers
|
||||
include routes.mounted_helpers
|
||||
end
|
||||
|
||||
if helpers
|
||||
include helpers
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -166,22 +166,6 @@ module ActionView #:nodoc:
|
|||
def xss_safe? #:nodoc:
|
||||
true
|
||||
end
|
||||
|
||||
# This method receives routes and helpers from the controller
|
||||
# and return a subclass ready to be used as view context.
|
||||
def prepare(routes, helpers) #:nodoc:
|
||||
Class.new(self) do
|
||||
if routes
|
||||
include routes.url_helpers
|
||||
include routes.mounted_helpers
|
||||
end
|
||||
|
||||
if helpers
|
||||
include helpers
|
||||
self.helpers = helpers
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
attr_accessor :view_renderer
|
||||
|
|
Loading…
Reference in a new issue