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

chris salvi
chris salvi
7,584 Points

can someone help me find the bug in my ODOT program?

Im rubbish reading errors, and I think it will be relatively minor ie forgot an end to close a block, but I would appreciate if someone could take a look at my code on github and see whats going on.

https://github.com/donsalvadori

Also if you have the time, can you tell me how you came to find the error?

chris salvi
chris salvi
7,584 Points

@Maciej Czuchnowski

Brandon Barrette
Brandon Barrette
20,485 Points

I would like help you, but I can't dig through all your code to hunt down errors. If you want to be a programmer, you have to learn to find the errors and understand them. If you want to post the error here, I would be more than willing to give you advice on how to resolve it.

chris salvi
chris salvi
7,584 Points

sorry Brandon Barrette I did not mean to sound bossy. I do tend to find the errors myself, just this one has given me some trouble.

when I run bin/rake here is the output:

/Users/salvi/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in load': /Users/salvi/rprojects/odot/spec/controllers/password_resets_controller_spec.rb:25: syntax error, unexpected tSYMBEG, expecting '(' (SyntaxError) ...ctionMailer::Base.deliveries. :size) ... ^ /Users/salvi/rprojects/odot/spec/controllers/password_resets_controller_spec.rb:118: syntax error, unexpected end-of-input, expecting keyword_end from /Users/salvi/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:inblock in load_spec_files' from /Users/salvi/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in each' from /Users/salvi/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:inload_spec_files' from /Users/salvi/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:18:in run' from /Users/salvi/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:103:inrun' from /Users/salvi/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:17:in `block in autorun'

chris salvi
chris salvi
7,584 Points

I noticed some minor spelling errors that I corrected. I will keep chipping away at the bugs and ask questions when needed. Sorry to bug you.

Brandon Barrette
Brandon Barrette
20,485 Points

You're not bothering! I wouldn't be trying to help if that was the case. It's just that since I am not sitting at your computer, the more information you can give in your forum posts the better for your fellow learners to help you.

It can get frustrating, happens to me all the time. Worst part is when you are looking for the error in the wrong file. I've wasted countless hours doing just that!

2 Answers

Brandon Barrette
Brandon Barrette
20,485 Points

Line 25:

expect{ post :create, email: user.email}.to change(ActionMailer::Base.deliveries. :size)

I don't want to tell you what's wrong completely, but in the change, you want there to be 2 arguments, and arguments are separated by a comma.

chris salvi
chris salvi
7,584 Points

yeah I noticed the period after deliveries looks wrong. Im guessing it should look like

(.... deliveries, :size)

Brandon Barrette
Brandon Barrette
20,485 Points

Bingo =) I hate when this happens. The hint here for future reference is this:

syntax error, unexpected tSYMBEG, expecting '(' (SyntaxError) ...ctionMailer::Base.deliveries. :size) ... ^ 

Notice the error told you the line and even the snippet of code. SyntaxError means something is typed wrong versus an error in your logic. Most of the time this means you have a comma, period, parenthesis, something in the wrong place.

chris salvi
chris salvi
7,584 Points

do you have any general comments about reading errors better? Right now I find them difficult to read cause the terminal just spews out a bunch of incoherent lines and no line breaks between errors. Surely theres some plugin I can download to rectify this issue. I run a mac OSX btw.

Brandon Barrette
Brandon Barrette
20,485 Points

Not really. The error you want to look for happens in the first few lines usually. I always look for the file names of the file I'm working on. You'll see a bunch of other lines of error code (that's the internals from ruby/rails).

I look for a line number and a file and hunt it down. It's a process. I've been using ruby/rails for just about a year and certainly wouldn't call myself an expert. But every time you get an error, it's an opportunity to learn why to prevent yourself form making that mistake again. Eventually you'll start to see common errors and know exactly where to find them.

Happy coding!

chris salvi
chris salvi
7,584 Points

/Users/salvi/rprojects/odot/app/controllers/todo_items_controller.rb:19: syntax error, unexpected '=', expecting keyword_end (SyntaxError) flash [:error] ="There was a problem adding that todo list item."

What about this one? Not sure where to go from here.

Update: I think the error is somewhere in my views/users/_form.html.erb

<%= form_for(@user) do |f| %>
  <% if @user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>

<ul>
      <% @user.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>
Brandon Barrette
Brandon Barrette
20,485 Points

What does the error say? Look specifically at the first line. It tells you which controller and which line to look at. It even tells you that there is something wrong with the "=" on that line.

chris salvi
chris salvi
7,584 Points

so im not that obtuse, but Im confused why it's pointing me to the = in the flash :error. I looked on the web and found a similar question about this but not in the case of created users, so that's what lead me to post my _form.html.erb

chris salvi
chris salvi
7,584 Points

im almost positive the error is not the equal sign in the controller despite it pointing me to there. I am simply assigning a string message to the assign operator =

Brandon Barrette
Brandon Barrette
20,485 Points

You've got a space between flash and [:error] where there shouldn't be one.

chris salvi
chris salvi
7,584 Points

ugh ruby is so specific about spaces :( Thanks mate!