Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Even i add the validate in the model i got the same error
I added the validation in the model but i got the same error
class TodoItem < ActiveRecord::Base belongs_to :todo_list validates :content, presence: true end
1) Creating todo items displays error with no content Failure/Error: expect(page).to have_content("There is a problem with adding a todo list item") expected to find text "There is a problem with adding a todo list item" in "Added todo list item." # ./spec/features/todo_items/create_spec.rb:31:in `block (3 levels) in <top (required)>' # ./spec/features/todo_items/create_spec.rb:30:in `block (2 levels) in <top (required)>'
Sorry guys i miss ":" next to the new in the controller
class TodoItemsController < ApplicationController def index @todo_list = TodoList.find(params[:todo_list_id]) end 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 end