Rails 3.2 ActionView MissingTemplate 仅在生产中

发布于 2025-01-03 08:43:34 字数 3791 浏览 6 评论 0原文

我有一个在开发模式下运行良好的应用程序。在尝试在 Webrick 或 Passenger/apache 中进行生产测试时,我的大部分站点加载良好,直到我尝试提交 ajax 表单。我已经正确使用了bundle install --deployment。我已经正确预编译了我的资产。但由于某种原因,我在提交远程表单时收到以下错误。请记住,ajax 实际上是在数据库中创建记录时工作的。我发现有趣的一件事是,我正在使用 ruby​​ 1.9.3 的 gemset,但我在这些错误代码中得到了对 ruby​​ 1.9.1 的引用。我还包括了用户控制器,以便您可以看到控制器引用。帮助!

更新!!取决于什么操作,无论是创建操作、编辑操作、更新操作还是销毁错误,缺少模板用户/创建或用户/更新或用户/编辑用户/销毁等。阅读评论关于第一个答案,因为我认为这是 javascript 文件未包含在预编译过程中的问题。

Started GET "/users/5" for 24.163.20.124 at 2012-02-07 03:30:09 -0500
Processing by UsersController#show as HTML
  Parameters: {"id"=>"5"}
Completed 500 Internal Server Error in 58ms

ActionView::MissingTemplate (Missing template users/show, application/show with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
* "/home/ctilley/Development/RatatouilleCatering/app/views"
* "/home/ctilley/Development/RatatouilleCatering/vendor/bundle/ruby/1.9.1/gems/wash_out-0.3.1/app/views"
* "/home/ctilley/Development/RatatouilleCatering/vendor/bundle/ruby/1.9.1/gems/ckeditor-3.7.0.rc2/app/views"
):
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/path_set.rb:58:in `find'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/lookup_context.rb:109:in `find'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/renderer/abstract_renderer.rb:3:in `find_template'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/renderer/template_renderer.rb:28:in `determine_template'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/renderer/template_renderer.rb:10:in `render'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/renderer/renderer.rb:36:in `render_template'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/renderer/renderer.rb:17:in `render'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/abstract_controller/rendering.rb:109:in `_render_template'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/streaming.rb:225:in `_render_template'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/abstract_controller/rendering.rb:103:in `render_to_body'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/abstract_controller/rendering.rb:88:in `render'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/rendering.rb:16:in `render'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.0/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'

控制器/users_controller.rb

class UsersController < ApplicationController

  before_filter :require_user
  respond_to :html, :js
  load_and_authorize_resource
def index
  @users = User.search(params[:search]).order(sort_column + " " + sort_direction).paginate(:per_page => 10, :page=>params[:page])

   authorize! :read, @article
end

def show
end

def create
  @user = User.new(params[:user])

  if @user.save
  respond_with @user, :location => users_url
  end
end

def destroy
  @user = User.find(params[:id])
  @user.destroy

  respond_with @user, :location => users_url
end

def edit
  @user = User.find(params[:id])
  respond_with @user, :location => users_url
end

def update
  @user = User.find(params[:id])
  @user.update_attributes(params[:user])

  respond_with @user, :location => users_url
end
private
def sort_column
  params[:sort] || "id"
end
def sort_direction
   params[:direction] || "asc"
 end

end

I have an application that works beautifully in development mode. In an attempt to test in production in Webrick or Passenger/apache most of my site loads well until I try to submit an ajax form. I have properly used bundle install --deployment. I've properly precompiled my assets. But for some reason I'm getting the following error when submitting remote forms. Keep in mind, the ajax is actually working as it is creating records in the database. One thing I find interesting is that I am using a gemset with ruby 1.9.3 but I am getting references to ruby 1.9.1 in these error codes. I'm also including the Users controller so you can see the controller references. Help!

Update!! Depending on what action whether it be the create action, edit action update action or destroy the error is missing template users/create or users/update or users/edit users/destroy etc. Read comment on the first answer as I believe this is an issue with the javascript files not being included in the precompile process.

Started GET "/users/5" for 24.163.20.124 at 2012-02-07 03:30:09 -0500
Processing by UsersController#show as HTML
  Parameters: {"id"=>"5"}
Completed 500 Internal Server Error in 58ms

ActionView::MissingTemplate (Missing template users/show, application/show with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
* "/home/ctilley/Development/RatatouilleCatering/app/views"
* "/home/ctilley/Development/RatatouilleCatering/vendor/bundle/ruby/1.9.1/gems/wash_out-0.3.1/app/views"
* "/home/ctilley/Development/RatatouilleCatering/vendor/bundle/ruby/1.9.1/gems/ckeditor-3.7.0.rc2/app/views"
):
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/path_set.rb:58:in `find'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/lookup_context.rb:109:in `find'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/renderer/abstract_renderer.rb:3:in `find_template'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/renderer/template_renderer.rb:28:in `determine_template'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/renderer/template_renderer.rb:10:in `render'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/renderer/renderer.rb:36:in `render_template'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_view/renderer/renderer.rb:17:in `render'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/abstract_controller/rendering.rb:109:in `_render_template'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/streaming.rb:225:in `_render_template'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/abstract_controller/rendering.rb:103:in `render_to_body'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/abstract_controller/rendering.rb:88:in `render'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/rendering.rb:16:in `render'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.0/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.0/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'

controllers/users_controller.rb

class UsersController < ApplicationController

  before_filter :require_user
  respond_to :html, :js
  load_and_authorize_resource
def index
  @users = User.search(params[:search]).order(sort_column + " " + sort_direction).paginate(:per_page => 10, :page=>params[:page])

   authorize! :read, @article
end

def show
end

def create
  @user = User.new(params[:user])

  if @user.save
  respond_with @user, :location => users_url
  end
end

def destroy
  @user = User.find(params[:id])
  @user.destroy

  respond_with @user, :location => users_url
end

def edit
  @user = User.find(params[:id])
  respond_with @user, :location => users_url
end

def update
  @user = User.find(params[:id])
  @user.update_attributes(params[:user])

  respond_with @user, :location => users_url
end
private
def sort_column
  params[:sort] || "id"
end
def sort_direction
   params[:direction] || "asc"
 end

end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

献世佛 2025-01-10 08:43:34

将以下内容移至 Gemfile 中的资产组之外

gem 'coffee-rails', "~> 3.2.1"
gem 'uglifier', ">= 1.0.3"

move the following outside of the assets group in your Gemfile

gem 'coffee-rails', "~> 3.2.1"
gem 'uglifier', ">= 1.0.3"
稍尽春風 2025-01-10 08:43:34
ActionView::MissingTemplate (Missing template users/show...)

这意味着视图文件 app/users/show.html.erb 丢失。在这里创建一个虚拟文件,看看这是否可以解决问题。

ActionView::MissingTemplate (Missing template users/show...)

This means that view file app/users/show.html.erb is missing. Create a dummy file here and see if this solves the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文