使用js jQuery的Rails 3.1中的错误 - “模板丢失” [英] Error in Rails 3.1 using js jQuery - "Template is missing"
问题描述
我根据这篇文章创建了应用 http://stjhimy.com/posts/7-creating-a-100-ajax-crud-using-rails-3-and-unobtrusive-javascript ,但收到错误:
I created app according to this post http://stjhimy.com/posts/7-creating-a-100-ajax-crud-using-rails-3-and-unobtrusive-javascript , but get an error:
Missing template posts/create, application/create with {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:html], :locale=>[:en, :en]}. Searched in: * "/home/ember/Projects/test_app/app/views"
也许在Rails中3.1默认情况下,动作会呈现一些此外,没有格式js(:formats => [:html])。但我找不到任何关于此的信息。
Maybe in Rails 3.1 actions render something by default. Besides, there no format js (:formats=>[:html]). But i can`t find any about this.
当我这样做时:
respond_to do |format|
format.js {render :content_type => 'text/javascript'}
end
或没有content_type - 浏览器重定向到空白页面。
在这种情况下:
or without content_type - browser redirects to empty page. In this case:
respond_to do |format|
format.js
format.html {render :nothing => true}
end
浏览器显示相同的空白页面。我怎么能在没有重定向的情况下做到这一点?
browser shows the same empty page. How can i do that without any redirects?
也许它是旧方法?
推荐答案
发布您到达此处的答案,以便其他人知道:
Posting the answer you arrived at here so others will know:
使用Rails 3.1,您不再需要手动包含 rails.js
您的应用程序中的文件(或者 jquery.js
文件)。在 Gemfile
中使用 gem'jquery-rails'
已经包含了这些内容。
With Rails 3.1, you no longer need to manually include the rails.js
file in your application (or the jquery.js
file for that matter). Having gem 'jquery-rails'
in your Gemfile
will already include these for you.
当你手动包含这些文件的旧前Rails 3.1版本时,它可能会干扰正确的javascript / jQuery功能。
When you do manually include old pre-Rails 3.1 versions of these files, it could interfere with proper javascript/jQuery functionality.
这篇关于使用js jQuery的Rails 3.1中的错误 - “模板丢失”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!