我在访问时收到一条错误消息,提示“nil:NilClass 的未定义方法 `verses'”
/books/1/chapters/1/verses/new
我的路线.rb:
resources :books do
resources :chapters do
resources :verses
end
end
verse_controller.rb:
class VersesController < ApplicationController
before_filter :find_book
before_filter :find_chapter, :only => [:show, :edit, :update, :destroy]
def new
@verse = @chapter.verses.build
end
private
def find_book
@book = Book.find(params[:book_id])
end
def find_chapter
@chapter = Chapter.find(params[:chapter_id])
end
end
关于如何解决这个问题的任何建议?