繁体   English   中英

Rails 3.1 response_with在生产中不起作用

[英]Rails 3.1 respond_with does not work in production

我有一个视图文件夹,其中包含许多在执行各种控制器操作时都会调用的js.coffee文件。 提交远程表单时调用该方法,并在控制器中由response_with行触发。 我以create方法为例。 重要的是要注意,所有这些功能都可以在开发模式下正常运行。 在生产中,我确保已经预编译了我的资产,运行了bundle install --deployment等。

users_controller.rb

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

  if @user.save
    respond_with @user, :location => users_url    #This line is throwing the error in production
  end
end

保存记录后,应执行以下Jquery,并且在开发模式下可以完美执行。 重要的是要注意,记录已创建,但是以下文件从未执行

create.js.coffee

$('#errors').empty()
$('#errors').show()
<% if @user.errors.any? %>
  $('<%= escape_javascript(render :partial => "errors", :locals => {:target => @user })%>')
  .appendTo('#errors')
<% else %>
  $('<%= escape_javascript(render(:partial => @user))%>')
  .appendTo('#user_table')
  .hide()
  .fadeIn(200)
  $('#errors').hide()
  $('#new_user')[0].reset()
  $('#users_count').html '<%= users_count %>'
<% end %>
$('#error_close').click ->
$('#errors').fadeOut()

这是在生产中引发的错误。

ActionView::MissingTemplate (Missing template users/create, application/create with {:locale=>[:en], :formats=>[:js, :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"
):
app/controllers/users_controller.rb:19:in `create'

我终于想通了。 从:assets组中取出coffee-rails和uglifier,这可以解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM