Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Daniel Lee
Daniel Lee
3,355 Points

Why does @todo_list.todo_items.new(todo_item_params) in create need to pass parameters but not within the new function?

def new @todo_list = TodoList.find(params[:todo_list_id]) @todo_item = @todo_list.todo_items.new end

def create @todo_list = TodoList.find(params[:todo_list_id]) @todo_item = @todo_list.todo_items.new(todo_item_params) if @todo_item.save flash[:success] = "Added todo list item." redirect_to todo_list_todo_items_path else flash[:error] = "There was a problem adding that todo list item." render action: :new end end

private def todo_item_params params[:todo_item].permit(:content) end

Please format your question so the code is readable - click on 'Markdown Cheatsheet' for instructions on how to do that.