ruby on rails - Error when calling a partial: SQLite3::SQLException: no such column: -


i've browsed stackoverflow answer error , haven't had luck in trying out solutions other questions. i'm new rails , i'm doing to-do list app project. when i'm attempting view todo_list#show view, i'm getting following error on line #2:

sqlite3::sqlexception: no such column: todo_items.todo_list_id: select "todo_items".* "todo_items" "todo_items"."todo_list_id" = ?

show view

<div id="todo_items_wrapper">    <p><%= render @todo_list.todo_items %></p> #this line highlighted error <div id="form">     <%= render "todo_items/form" %>    </div> </div> 

i'm attempting call following partial on line #2; here partial file:

<%= form_for([@todo_list, @todo_list.todo_items.build]) |f| %>   <%= f.text_field :content, placeholder: "new todo" %>   <%= f.submit %> <% end %> 

i'm assuming have issue migrations since error stating missing column don't have clue how iron out problem. below migration files if needed:

migration files

class createtodolists < activerecord::migration   def change     create_table :todo_lists |t|       t.string :title       t.text :description        t.timestamps null: false     end   end end 

and...

class createtodoitems < activerecord::migration   def change     create_table :todo_items |t|       t.string :content       t.references :todo_lists, index: true, foreign_key: true        t.timestamps null: false     end   end end 

schema

activerecord::schema.define(version: 20160203002224)    create_table "todo_items", force: :cascade |t|     t.string   "content"     t.integer  "todo_lists_id"     t.datetime "created_at",    null: false     t.datetime "updated_at",    null: false   end    add_index "todo_items", ["todo_lists_id"], name: "index_todo_items_on_todo_lists_id"    create_table "todo_lists", force: :cascade |t|     t.string   "title"     t.text     "description"     t.datetime "created_at",  null: false     t.datetime "updated_at",  null: false   end  end 

let me know if other files needed error. thank you!

error due wrong name in migration file (todo_lists, should todo_list)

 t.references :todo_lists, index: true, foreign_key: true 

should

 t.references :todo_list, index: true, foreign_key: true 

you can write migration rename column name fix it.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -