New Rails user here trying to create a basic todolist app in rails 3.2.6
and running into some foreign key issues. Here’s what I did…
I generated scaffolds
list title:string & task description:text listname:string
Next, in order to link the listname for Tasks and the list titles in the
Lists I generated a migration file which looks like this
class AddListIdToTasks < ActiveRecord::Migration
add_column :tasks, :list_id, :integer
I then added active record association has_many :tasks and for the Task
I used belongs_to :list (, :foreign_key => “list_id)” - even though I
think this last part was unnecessary).
Finally I ran rake db:migrate.
Now I have the table setup (checked it in SQLite Database Browser), but
am running into errors interacting with my forms when I run the rails
server. I know I have some problems with my views and have tried
changing around the _form.html.erb and other .erb files to reflect
:list_id as opposed to :list_name, but I can’t figure out what I need to
do to get the list id into the database table for the tasks. Any ideas
or advice? Would be very much appreciated.
Thank you so much!