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 trialJesse Johnston
13,494 PointsBuilding a validation that checks :city presence and its length
Hey All!
First post here on Treehouse. I'm having issues getting my code to pass for this test... I'm sure it's something small but I just can't seem to figure it out. Can anyone spot any issues with this?
TREEHOUSE QUESTION: Build a validation that checks a field called :city to ensure that itβs between 2 and 30 characters long, and is present.
MY RESPONSE:
class Contact < ActiveRecord::Base
validates :city, presence: true, length: {in 2..30}
end
2 Answers
Hampton Catlin
Treehouse Guest TeacherHey Jesse! Looks like the issue is with the in keyword. As you have it, it's not a valid Ruby hash.
class Contact < ActiveRecord::Base
validates :city, presence: true, length: {in: 2..30}
end
Hope this helps!
Jesse Johnston
13,494 PointsWhoa! I thought you only lived in the fictional world of Treehouse Island!
Thanks for the response Hampton, you're the man!