Given Rails 4.2, Ruby 2.3.1.
In theory, Rails should allow you to completely reset the view paths, as seen here, in the source code.
However, when I reset the view_paths via #view_paths=
, from a controller callback, something unexpected happens.
> view_paths.size
=> 2
> new_paths = view_paths.reject { |vp| rejection criteria }
> new_paths.size
=> 1
> view_paths = new_paths
> view_paths.size
=> 2
> _view_paths.size
=> 1
self._view_paths
has successfully been reset, but #view_paths
has not picked up those changes, despite simply being a wrapper for self._view_paths
. Why is self._view_paths
correct, and #view_paths
not?
Note: This is important because Rails uses #view_paths
when searching for view, not self._view_paths
.