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???

Leave a Reply




Created by DesignForWeb company. All rights reserved © 2007-2010. Check also the iPhone / iPad developers blog
Disclaimer
The materials collected in this blog were taken from open access sources. We try our best to preserve the copyrights of original authors and clearly state the authorship as well as link to original source website where it's possible. Please leave your comment if you feel offended by any post or if you dispose of any information about breach of copyright law in this blog. We will do our best to resolve the situation immediately.