Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Modified views outside of config.view_path are not recompiled in development mode

#1764

In my controller I prepend an alternative view path:


class TestController < ApplicationController
  prepend_view_path "#{RAILS_ROOT}/templates"

  def index; end
end

config.view_path is not changed in environment.rb (default is obviously "#{RAILS_ROOT}/app/views"). config.cache_classes is also unchanged from the default.

Modifying RAILS_ROOT/templates/test/index.html.erb has no effect after the first request to :index.

Apologies for the lack of a test case or patch at this stage. After spending hours staring at the ActionView internals, it is still mostly voodoo to me.

Reported by Sam Pohlenz · January 15th, 2009 @ 07:33 PM

State: resolved
Milestone: none
Assigned to: josh josh
Importance: none

Activity

  1. DHH
    DHH
    • Milestone cleared.
    • Assigned user set to josh

    February 3rd, 2009 @ 06:33 PM

  2. Andrew White
    Andrew White

    Found the cause - the additional view paths are added as ActionView::Template::EagerPath whereas the initial 'app/views' is added as a simple ActionView::Template::Path.

    The quick and dirty fix is for ActionView::PathSet.type_cast to type cast to Path when cache_classes is false rather than EagerPath. However it may be more beneficial to try and refactor the code to get template reloading working in production mode as well.

    February 4th, 2009 @ 04:53 PM

  3. Andrew White
    Andrew White
    • Tag changed from actionpack, actionview, views to actionpack, actionview, patch, views

    Patch for the quick and dirty fix. No tests - not quite sure how to test modification of a template file being reloaded.

    February 4th, 2009 @ 05:01 PM

  4. josh
    josh
    • State changed from new to wontfix

    Applying the patch breaks many unit tests.

    Maybe EagerPath should still be the default? Would that still solve the problem?

    February 5th, 2009 @ 09:27 PM

  5. Andrew White
    Andrew White

    Defaulting to EagerPath breaks reloading everywhere including app/views so I don't think that's going to be acceptable!

    Looking at the test failures (after defining Rails) they all seem to be of the type:

    <ActionView::Template::EagerPath> expected but was <ActionView::Template::Path>.

    which is obviously easy to fix, however I'm wondering whether it might be better to try and fix it at a more fundamental level and bring back support for reloading templates in production mode as well. The question is would such a large patch be accepted at this stage of the 2.3 release?

    February 5th, 2009 @ 11:54 PM

  6. josh
    josh

    I meant flipping the conditional, so if no Rails const is available default to eager so the AP tests pass.

    February 6th, 2009 @ 12:13 AM

  7. Andrew White
    Andrew White

    Sorry, yes that works - attached patch passes all tests and reloads templates outside of app/views.

    February 6th, 2009 @ 12:41 AM

  8. josh
    josh
    • State changed from wontfix to open

    February 6th, 2009 @ 01:27 AM

  9. Repository
    Repository
    • State changed from open to resolved

    (from [bccd2c54b2c7708f881faf9c9464dcf29bd30bef]) Use Path rather than EagerPath when cache_classes == false so other view paths are properly recompiled in development mode [#1764 Modified views outside of config.view_path are not recompiled in development ... state:resolved] Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

    February 6th, 2009 @ 01:57 AM