Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 不能';我找不到与';id';_Html_Ruby On Rails_Ruby_Slim Lang - Fatal编程技术网

Html 不能';我找不到与';id';

Html 不能';我找不到与';id';,html,ruby-on-rails,ruby,slim-lang,Html,Ruby On Rails,Ruby,Slim Lang,大家好,我到处寻找这个问题的答案,所以我终于要在这里提问了。我是一个尝试学习html和ruby的新程序员。我正在编写一个非常简单的todo应用程序,但我不知道如何修复此错误: “找不到id为“”的待办事项” todos_controller.rb edit.html.slim index.html.slim routes.rb 编辑: 我的编辑视图与现在写的完全一样 我要离开这个教程了 如果我的格式错误,请道歉,第一次在此处提问。您试图将编辑链接链接链接到所有@todo,但它应该链接到单个tod

大家好,我到处寻找这个问题的答案,所以我终于要在这里提问了。我是一个尝试学习html和ruby的新程序员。我正在编写一个非常简单的todo应用程序,但我不知道如何修复此错误:

“找不到id为“”的待办事项”

todos_controller.rb

edit.html.slim

index.html.slim

routes.rb

编辑:

我的编辑视图与现在写的完全一样

我要离开这个教程了


如果我的格式错误,请道歉,第一次在此处提问。

您试图将编辑链接链接链接到所有@todo,但它应该链接到单个
todo

= link_to "Edit", edit_todo_path(todo)

如果查看index.html.slim,则需要传递一个todo值,而不是所有todo:

// @todos contains a collection of all the todos
- @todos.each do |todo|
  // inside this block todo contains your single todo
  ul
    li=todo.item 
  p
    = link_to "New", new_todo_path
  p
    = link_to "Edit", edit_todo_path(todo) #notice it's todo not @todos
  p
    = link_to "Delete", '#'
这将解决您的上述错误,但您的edit.html.slim中还有另一个错误,因此您也需要修复该错误,否则它将给您带来另一个错误,在您的表单中,您必须使用@todo not@link


另外,如果您想显示表单的验证错误,那么在创建方法中,您应该使用.save而不是.create,checkout

我想我的gems或rails或其他东西有问题吗?我准确地复制了你的代码,它给了我另一个错误“C:/row/todo list app/app/views/todos/index.html.slim:22:语法错误,意外的关键字“\u end,预期“)”—————————————是的,我将删除早期的,抱歉。@dwagz1313您能显示完整错误以及您在哪一行获得此信息吗c:/row/todo list app/app/views/todos/index.html.slim:22:语法错误,意外的关键字_end,应为“')@输出缓冲区安全连接(“

”);结束@output_buffer^C:/row/todo list app/app/views/todos/index.html.slim:25:语法错误,意外的关键字_end,应为“')”提取源(第22行附近):p=link_至“Delete”,“#”@dwagz1313这看起来更像是缩进错误,正如我刚才在前面的评论中解释的,当您使用haml或slim时,您不会关闭块。只要确保所有东西都正确缩进就行了
= form_for(@link) do |f|
 p
   = f.text_field :item
 p
   = f.submit
- @todos.each do |todo|
  ul
        li=todo.item 

p
 = link_to "New", new_todo_path
p
 = link_to "Edit", edit_todo_path(@todos)
p
 = link_to "Delete", '#'
Rails.application.routes.draw do
root to: "todos#index"
 resources :todos
end
= form_for(@todo) do |f|
  p
   = f.text_field :item
  p
   = f.submit
= link_to "Edit", edit_todo_path(todo)
// @todos contains a collection of all the todos
- @todos.each do |todo|
  // inside this block todo contains your single todo
  ul
    li=todo.item 
  p
    = link_to "New", new_todo_path
  p
    = link_to "Edit", edit_todo_path(todo) #notice it's todo not @todos
  p
    = link_to "Delete", '#'
= form_for @todo do |f|
  // fields