0
出于某种原因而试图呈现其部分的显示链接抛出错误,即使局部存在(名为_show.html.erb)Rails的部分错误缺少模板即使有
再没更改路线文件。它只是有根宣言和resources :notes
而且我没有删除由脚手架生成的原始 “show.html.erb”。(问题?)
index.html.erb
<% @notes.each do |note| %>
<% note.title %>
<%= link_to 'Show', note, remote: true, class: "note-show" %>
<% end %>
<div id="note-show">
</div>
_show.html.erb
<% note.title %>
<% note.body %>
个show.js.erb
$('#note-show').html("<%= render :partial => 'show' %>");
笔记控制器
class NotesController < ApplicationController
before_action :set_note, only: [:show, :edit, :update, :destroy]
def index
@notes = Note.all.order('created_at DESC')
end
def show
respond_to do |format|
format.js
format.html
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_note
@note = Note.find(params[:id])
end
错误是
ActionView::MissingTemplate in Notes#show
Showing /home/arjun/rails/notes/app/views/notes/show.html.erb where line # raised:
Missing partial notes/_show, application/_show with {:locale=>[:en], :formats=>[:js, :html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
* "/home/arjun/rails/notes/app/views"
* "/home/arjun/.rvm/gems/ruby-1.9.1-p431/gems/twitter-bootstrap-rails-3.2.0/app/views"
奇怪的是一些链接它只是表明
$('#note-show').html("hello
");
我通过使用浏览器页面发现此页面源代码
这里有什么不正确?
http://stackoverflow.com/questions/1620113/why-escape-javascript-before-rendering-a -partial – AbM