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 trialjooyoonbyun
3,438 Pointssyntax error, unexpected end-of-input, expecting keyword_end
Hi, I am getting syntax error, unexpected end-of-input, expecting keyword_end message like the picture below and I have found nothing was wrong.
Failures:
1) Adding todo items is successful with valid content
Failure/Error: click_link "List Items"
SyntaxError:
/Library/WebServer/Documents/odot/app/controllers/todo_items_controller.rb:27: syntax error, unexpected end-of-input, expecting keyword_end
# ./spec/features/todo_items/create_spec.rb:9:in `block in visit_todo_list'
# ./spec/features/todo_items/create_spec.rb:8:in `visit_todo_list'
# ./spec/features/todo_items/create_spec.rb:14:in `block (2 levels) in <top (required)>'
and this is my todo_items_controller.rb
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
private
def todo_item_params
params[:todo_item].permit(:content)
end
end
1 Answer
Jaro Schwab
8,957 PointsHey..
I think you need to end your If.. else Statement..
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 the If Statement
end