所以,我从todo_controller.rb
中得到了这个错误class TodoController < ApplicationController
def index
@todos = Todo.where(done: false)
@todone = Todo.where(done: true)
end
def new
@todo = Todo.new
end
def todo_params
params.require(:todo).permit(:name, :done)
end
def create
@todo = Todo.new(todo_params)
if @todo.save
redirect_to todo_index_path, :notice => "Your todo item was created!"
else
render 'new'
end
end
def update
@todo = Todo.find(params[:id])
if @todo.update_attribute(:done, true)
redirect_to todo_index_path, :notice => "Your todo item was marked as done!"
else
redirect_to todo_index_path, :notice => "Your todo item wasn't marked as done!"
end
end
def destroy
@todo = Todo.find(params[:id])
@todo.destroy
redirect_to todo_index_path, :notice => "Your todo task has been deleted!"
end
end
我用谷歌搜索它,发现应该有一个同名的模块。我发现它是config / application.rb,我将其更改为Module todoo,但我再次遇到同样的错误。
答案 0 :(得分:0)
我只是完全重写了应用程序,并且它有效。我想我手动做了一些事情应该由Rails自动完成,并且哪一切都出错了。