我在尝试编辑模型时遇到问题。我总是以错误告终
undefined method `model_name' for NilClass:Class
我在视图中使用:
<%= form_for(@book) do |f| %>
在控制器上:
def edit
@title = "Edit Book"
end
def update
@book = Book.find(params[:id])
if @book.update_attributes(params[:book])
flash[:success] = "Book Updated"
redirect_to @book
else
@title = "Edit Book"
render 'edit_book_path(@book)'
end
end