【发布时间】:2011-08-18 02:46:08
【问题描述】:
我根据http://stjhimy.com/posts/7-creating-a-100-ajax-crud-using-rails-3-and-unobtrusive-javascript这个帖子创建了应用,但是报错:
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 中,action 默认会渲染一些东西。此外,没有格式 js (:formats=>[:html])。但我找不到任何关于此的信息。
当我这样做时:
respond_to do |format|
format.js {render :content_type => 'text/javascript'}
end
或没有 content_type - 浏览器重定向到空白页面。 在这种情况下:
respond_to do |format|
format.js
format.html {render :nothing => true}
end
浏览器显示相同的空白页面。我怎么能在没有任何重定向的情况下做到这一点?
也许这是旧方法?
【问题讨论】:
-
您能否发布提交表单的视图代码,以便我们查看您如何调用
posts/create? -
哦,问题出在我添加的 rails.js 文件上,它无法正常工作。现在它可以工作文件,当我删除它时。对不起,我没有提到这个。所以,问题解决了,也许我需要以某种方式标记这个?
标签: javascript ruby ruby-on-rails-3 rendering ruby-on-rails-3.1