This project is archived and is in readonly mode.

#1764 ✓resolved
Sam Pohlenz

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

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

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.

Comments and changes to this ticket

  • DHH

    DHH February 3rd, 2009 @ 06:33 PM

    • Milestone cleared.
    • Assigned user set to “Joshua Peek”
  • Andrew White

    Andrew White February 4th, 2009 @ 04:53 PM

    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.

  • Andrew White

    Andrew White February 4th, 2009 @ 05:01 PM

    • 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.

  • Joshua Peek

    Joshua Peek February 5th, 2009 @ 09:27 PM

    • 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?

  • Andrew White

    Andrew White February 5th, 2009 @ 11:54 PM

    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?

  • Joshua Peek

    Joshua Peek February 6th, 2009 @ 12:13 AM

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

  • Andrew White

    Andrew White February 6th, 2009 @ 12:41 AM

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

  • Joshua Peek

    Joshua Peek February 6th, 2009 @ 01:27 AM

    • State changed from “wontfix” to “open”
  • Repository

    Repository February 6th, 2009 @ 01:57 AM

    • 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 state:resolved] Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages