我似乎无法在我的控制器中获取我的respond_to块来发送view.js

时间:2011-11-19 14:44:21

标签: jquery ajax ruby-on-rails-3

所以,我的模型上的创建操作有效,但它不会将javascript视图发送回浏览器。我经历了堆栈跟踪,发现了问题(我认为))

    Rendered posts/create.js.erb (51.0ms)
Completed 500 Internal Server Error in 1173ms

ActionView::Template::Error (undefined method `escape_javaScript' for #<#<Class:0x4924020>:0x491c598>):
    1: $('body').html("<h1><%= escape_javaScript(@post.title) %></h1>").append("<%= escape_javaScript(@post.content) %>");

  app/views/posts/create.js.erb:1:in `_app_views_posts_create_js_erb__102872654_38327136'
  app/controllers/posts_controller.rb:45:in `create'

Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (4.0ms)
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (3.0ms)
Rendered C:/Ruby192/lib/ruby/gems/1.9.1/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (54.0ms)

rails 3.1不支持'escape_javascript'吗?

1 个答案:

答案 0 :(得分:1)

它支持escape_javascript但不支持escape_javaScript。注意你的情况下的资本'S'。