This project is archived and is in readonly mode.

#1712 ✓resolved
Ngoc Dao

"Template is missing" error for engine in production environment

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

[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

Comments and changes to this ticket

  • Ngoc Dao

    Ngoc Dao January 8th, 2009 @ 01:23 PM

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

  • Stephan Kaag

    Stephan Kaag January 9th, 2009 @ 04:53 PM

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

  • Stephan Kaag

    Stephan Kaag January 11th, 2009 @ 01:36 PM

    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.

  • Stephan Kaag

    Stephan Kaag January 11th, 2009 @ 02:08 PM

    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.

  • Stephan Kaag

    Stephan Kaag February 2nd, 2009 @ 09:36 AM

    • Tag changed from actionview, edge, production, view to 2.3, actionview, production, view

    This problem also occurs in the RC for 2.3

  • marcbey

    marcbey February 3rd, 2009 @ 01:57 PM

    I get this error also on development environment.

  • DHH

    DHH February 6th, 2009 @ 01:42 PM

    • Assigned user set to “Yehuda Katz (wycats)”
    • Milestone cleared.
  • David Reese

    David Reese February 7th, 2009 @ 07:51 PM

    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.

  • Glenn Powell

    Glenn Powell February 7th, 2009 @ 08:51 PM

    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.

  • David Reese

    David Reese February 7th, 2009 @ 09:36 PM

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

  • Andrew White

    Andrew White February 8th, 2009 @ 10:38 AM

    I've just added ticket #1909 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.

  • Sven Fuchs

    Sven Fuchs February 9th, 2009 @ 09:02 AM

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

  • David Reese

    David Reese February 9th, 2009 @ 03:37 PM

    thanks sven... I realized ActionMailer wasn't getting the paths right but I went ahead and tried Andrew White's patch (on #1909) 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.)

  • Thijs

    Thijs February 14th, 2009 @ 10:07 AM

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

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

  • Andrew White

    Andrew White February 22nd, 2009 @ 06:42 AM

    Josh, I'm pretty sure you can close this ticket as being fixed by the changes in #1909. I can reproduce this error using 2.3.0 but I can't with edge.

  • josh

    josh February 22nd, 2009 @ 04:43 PM

    • Assigned user changed from “Yehuda Katz (wycats)” to “josh”
    • State changed from “new” to “resolved”

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