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

I have an error in Ruby in the biller app. I am getting an error with unexpected characters in a scope designation.

Here is the line of code as presented in the Scope video:

scope :starts_with, -> (letter) { where("name LIKE ?", letter + "%") } - caused a lot of errors

I changed it to - scope :starts_with, -> letter { where("name LIKE ?", letter + "%") } and it works. Does anyone know why?

Here is the full code from the 'customer.rb' file that actually seems to work, where the one with the () around 'letter' does not:

class Customer < Account has_many :time_entries scope :premier, -> { where("employees> ?", 30)} scope :newest, ->{ order("created_at DESC")} scope :starts_with, -> letter { where("name LIKE ?", letter + "%") } end

Thank you for your help!

Bob