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.

"Template is missing" error for engine in production environment

#1712

[Edge Rails]

  1. Create "my_app" engine (plugin with "app" directory) with proper routes.rb, controller, and view
  2. Start server in production environment (ruby script/server -e production) and goto http://localhost:3000/my_app, the error message below appears

Template is missing

Missing template my_app/index.erb in view path app/views

Reported by Ngoc Dao · January 8th, 2009 @ 01:11 PM

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

Activity

  1. Ngoc Dao
    Ngoc Dao

    The correct view path should be: vendor/plugins/my_app/app/views

    January 8th, 2009 @ 01:23 PM

  2. Stephan Kaag
    Stephan Kaag

    Same problem here. In development environment the engine works fine. In production it fails with the same error described above

    January 9th, 2009 @ 04:53 PM

  3. Stephan Kaag
    Stephan Kaag

    Calling @@ActionController::Base.view_paths@@ in Rails::Plugin::Loader's add_engine_view_paths seems to fix this as a workaround.

    A real solution is needed because this functionality is really broken at the moment.

    January 11th, 2009 @ 01:36 PM

  4. Stephan Kaag
    Stephan Kaag

    Problem found.

    The cause is this commit: http://github.com/rails/rails/co...

    In production environment the view-path is 'resetted' in the function 'load_view_paths'. The engines view-paths are left out.

    January 11th, 2009 @ 02:08 PM

  5. Stephan Kaag
    Stephan Kaag
    • Tag changed from actionview, edge, production, view to 2.3, actionview, production, view

    This problem also occurs in the RC for 2.3

    February 2nd, 2009 @ 09:36 AM

  6. marcbey
    marcbey

    I get this error also on development environment.

    February 3rd, 2009 @ 01:57 PM

  7. DHH
    DHH
    • Assigned user set to Yehuda Katz (wycats)
    • Milestone cleared.

    February 6th, 2009 @ 01:42 PM

  8. David Reese
    David Reese

    Here's a simple fix, just changes the existing ActionController::Base.view_paths to EagerPaths.

    ActionController::Base.view_paths is already set earlier (in initialize_framework_views, then added to in load_plugins if there are any engine plugins), so configuration.view_path is already in the view_paths -- no need to reference it again.

    February 7th, 2009 @ 07:51 PM

  9. Glenn Powell
    Glenn Powell

    Or another simple fix where you don't have to mess with the core code, is to just append the engine paths by hand into ApplicationController.view_paths at the end of your application_controller.rb file. This is just a hack until the core is fixed, of course, but it does the job.

    February 7th, 2009 @ 08:51 PM

  10. David Reese
    David Reese

    Thank you, Glenn, not messing with core code would have been a better idea!

    My last patch is wrong. There was of course more refactoring to be done.

    Paths are already added correctly as EagerPaths/Paths, depending on cache_classes config, through the setter method on AC::Base.view_paths... but only if they're added as strings, not as ActionView::Template::Path. So initialize_framework_views needed cleanup.

    Now, i'm not sure why #load_view_paths needs to exist at all. If there are any view paths, they've already been added correctly (eagerly), afaict.

    [there's of course another ticket somewhere RE: the view path confusion in ActionMailer (template_root vs view_paths).]

    now wycats, you probably know all this already and this would have taken you 5 minutes...

    February 7th, 2009 @ 09:36 PM

  11. Andrew White
    Andrew White

    I've just added ticket #1909 Improve view performance in development and reinstate template reloading in p... which should fix this problem along with some extra benefits. I'd be grateful if you could check it out and see if it fixes things for you.

    February 8th, 2009 @ 10:38 AM

  12. Sven Fuchs
    Sven Fuchs

    Trying to migrate a heavily engines-based app to 2.3 I've applied David's latest patch and it seems to work for me for ActionView view_paths. ActionMailer does not pick up templates from plugins though but instead breaks with a MethodMissing #find_template for class String (or something like that).

    I've come up with the attached patch which certainly is not the right way to solve it (i guess), but maybe it's helpful to point out what's breaking.

    (Ah, I should mention that the attached patch is based on David's latest one.)

    February 9th, 2009 @ 09:02 AM

  13. David Reese
    David Reese

    thanks sven... I realized ActionMailer wasn't getting the paths right but I went ahead and tried Andrew White's patch (on #1909 Improve view performance in development and reinstate template reloading in p...) and it both fixed the original problem (this ticket) and vastly sped up my dev environment.

    From what I can tell, ActionMailer is still not actually using all the view paths you send it -- in the initialize it gets templates from template root, which is:

    
          def template_root
            self.view_paths && self.view_paths.first
          end
    

    (Meanwhile I encountered an unsolvable bug in 2.3 where my cookies weren't being written correctly. Not even sure where to file that bug (rails? rack? passenger?) So i'm back to 2.2 and called it a day.)

    February 9th, 2009 @ 03:37 PM

  14. Thijs
    Thijs

    David, maybe this ticket has something to do with your cookies problem?

    http://rails.lighthouseapp.com:8...

    February 14th, 2009 @ 10:07 AM

  15. Andrew White
    Andrew White

    Josh, I'm pretty sure you can close this ticket as being fixed by the changes in #1909 Improve view performance in development and reinstate template reloading in p.... I can reproduce this error using 2.3.0 but I can't with edge.

    February 22nd, 2009 @ 06:42 AM

  16. josh
    josh
    • Assigned user changed from Yehuda Katz (wycats) to josh
    • State changed from new to resolved

    February 22nd, 2009 @ 04:43 PM