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 ActiveRecord Basics Validation Using Validations

Sarah A. Morrigan
Sarah A. Morrigan
14,329 Points

buggy code challenge again? (Stage 3 - Using Validations)

class Contact < ActiveRecord::Base
   validates :city, length: {in 2..30}, presence: true
 end

There is no discernible reason why this gives me an error.

It is exactly the same format as shown in video (2:31).

contact.rb
 class Contact < ActiveRecord::Base

 end

3 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Hi, Sarah, This line has minor bug

length: {in 2..30}   # missed a colon after in

# should be
length: {in: 2..30}

Hi Sarah,

Under length, I find little missing coma (':') that should be like {in: 2..30} :smile:

class Contact < ActiveRecord::Base
   validates :city, length: {in: 2..30}, presence: true
 end
Sarah A. Morrigan
Sarah A. Morrigan
14,329 Points

yikes! lol... duh

i need new glasses 8-)

Lol, yeah this is common minor mistakes like we don't know what's going on. :(