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 trialBlair Rorani
6,658 PointsHow do I correctly add a validation in RoR?
I added:
class TodoList < ActiveRecord::Base
validates: title, presence :true
end
to my RoR app and I get this error:
syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '(' validates :title, presence :true ^
in RoR 4.1.4.
1 Answer
Maciej Czuchnowski
36,441 PointsMove the colons from validates
to title
and from true
to presence
.
class TodoList < ActiveRecord::Base
validates :title, presence: true
end
Blair Rorani
6,658 PointsBlair Rorani
6,658 Points! thanks