How to insert an id?
Hey I am newer to rails and have a question again! I am trying to take an id an place it in the database see below:
Controller:
def addtodo
@todo = Todo.new(params[:todo])
@todo.account_id = session[:user_id]
@todo.stat = 1
@todo.list_id = :list_id
if @todo.save
flash[:notice] = 'Your todo was successfully created.'
redirect_to :action => 'list', :id => list
else
flash[:notice] = 'Sorry, we cant add the todo.'
end
end
Also, i am trying to redirect the user back to the list by using
redirect_to :action => 'list', :id => list
I know that is wrong but what is the right way?
The Model:
has_many :todos, :foreign_key => :list_id
Now the link on the page is (/list/2 <-- the id of the list) That id needs to go into the database. I have tried using (params[:id]) to get it but cant! What do I need to do, or what am I doing wrong???
