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

Build a Todo List With Rails 4 - Validating Length

EDIT: Found my answer!

After successfully completing my first two tests I started getting errors for all three when I saved my code. The error message appeared as such: ```[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. FFF

Failures:

1) Creating todo lists redirects to the todo list index page on succes Failure/Error: click_button "Create Todo list" NoMethodError: undefined method name' for #<TodoList:0xb9331b48> # ./app/controllers/todo_lists_controller.rb:30:inblock in create' # ./app/controllers/todo_lists_controller.rb:29:in create' # ./spec/features/todo_lists/create_spec.rb:11:inblock (2 levels) in <top (required)>'

2) Creating todo lists displays an error when the todo list has no title Failure/Error: click_button "Create Todo list" NoMethodError: undefined method name' for #<TodoList:0xba2a3978> # ./app/controllers/todo_lists_controller.rb:30:inblock in create' # ./app/controllers/todo_lists_controller.rb:29:in create' # ./spec/features/todo_lists/create_spec.rb:25:inblock (2 levels) in <top (required)>'

3) Creating todo lists displays an error when the todo list has a title less than 3 characters Failure/Error: click_button "Create Todo list" NoMethodError: undefined method name' for #<TodoList:0xba7a258c> # ./app/controllers/todo_lists_controller.rb:30:inblock in create' # ./app/controllers/todo_lists_controller.rb:29:in create' # ./spec/features/todo_lists/create_spec.rb:43:inblock (2 levels) in <top (required)>'

Deprecation Warnings:


RSpec::Core::ExampleGroup#example is deprecated and will be removed in RSpec 3. There are a few options for what you can use instead:

  • rspec-core's DSL methods (it, before, after, let, subject, etc) now yield the example as a block argument, and that is the recommended way to access the current example from those contexts.
  • The current example is now exposed via RSpec.current_example, which is accessible from any context.
  • If you can't update the code at this call site (e.g. because it is in an extension gem), you can use this snippet to continue making this method available in RSpec 2.99 and RSpec 3:

    RSpec.configure do |c| c.expose_current_running_example_as :example end

(Called from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>')


RSpec::Core::ExampleGroup#example is deprecated and will be removed in RSpec 3. There are a few options for what you can use instead:

  • rspec-core's DSL methods (it, before, after, let, subject, etc) now yield the example as a block argument, and that is the recommended way to access the current example from those contexts.
  • The current example is now exposed via RSpec.current_example, which is accessible from any context.
  • If you can't update the code at this call site (e.g. because it is in an extension gem), you can use this snippet to continue making this method available in RSpec 2.99 and RSpec 3:

    RSpec.configure do |c| c.expose_current_running_example_as :example end

(Called from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:21:in `block (2 levels) in <top (required)>')

If you need more of the backtrace for any of these deprecations to identify where to make the necessary changes, you can configure config.raise_errors_for_deprecations!, and it will turn the deprecation warnings into errors, giving you the full backtrace.

2 deprecation warnings total

Finished in 0.40621 seconds 3 examples, 3 failures

Failed examples:

rspec ./spec/features/todo_lists/create_spec.rb:4 # Creating todo lists redirects to the todo list index page on succes rspec ./spec/features/todo_lists/create_spec.rb:16 # Creating todo lists displays an error when the todo list has no title rspec ./spec/features/todo_lists/create_spec.rb:34 # Creating todo lists displays an error when the todo list has a title less than 3 characters

Randomized with seed 39741```

Noticing that the problem was with the click_button code I went back to my web browsers and tried to create a new list and an error appeared in the browser. It came back as: NoMethodError in TodoListsController#create undefined method `name' for #<TodoList:0xb8e685e4>

Extracted source (around line #30): 28 29 30 31 32 33

respond_to do |format|
  if @todo_list.save
    format.html { redirect_to @todo_list, notice: 'Todo list was successfully created.' }
    format.json { render action: 'show', status: :created, location: @todo_list }
  else

Rails.root: /home/treehouse/projects/odot

Application Trace | Framework Trace | Full Trace app/controllers/todo_lists_controller.rb:30:in block in create' app/controllers/todo_lists_controller.rb:29:increate' Request

Parameters:

{"utf8"=>"?", "authenticity_token"=>"LUMJDyOp8apM+f5TmLxb25Z9JdCb17Qf9IbX76d6mcI=", "todo_list"=>{"title"=>"", "description"=>""}, "commit"=>"Create Todo list"} Toggle session dump Toggle env dump Response

Headers:

None.

I'm really not sure what went wrong at this point or how to fix it. Any suggestions would be helpful.

P.S. If more information is need please let me know

2 Answers

Great! 1. Share it with a new post. 2. Edit original post with the first line saying something like

EDIT: Found my answer

That way, others won't waste their time reading through your post.

Never mind I found my answer!