For some reason the show link throws error while trying to render its partial, even though the partial exists (named _show.html.erb)
Made no changes to the routes file. It simply has the root declaration and resources :notes
And I have not deleted the original "show.html.erb" generated by Scaffold.(matters?)
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' %>");
notes controller
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
Error is
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"
Strangely on some links it simply shows
$('#note-show').html("hello
");
I found this by using the Browser Page Source
What is incorrect here?
Aucun commentaire:
Enregistrer un commentaire