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 Build a Simple Ruby on Rails Application Writing Tests Validations

Dillon Carter
Dillon Carter
6,364 Points

Stuck on Validating a users first, last and profile name

I've watched the videos a few times and for some reason I am drawing a complete blank.

Can someone explain this to me so I can understand what I am doing wrong?

My current code:

validates :first_name, :presence, :true

validates :last_name, :presence, :true

validates :profile_name, :presence, :true

end

2 Answers

John O.
John O.
4,680 Points

You have colons and commas in the wrong place. It should look like

validates :first_name, presence: true

Also, if all of your attributes are going have the same validation you can have a single definition with multiple parameters:

validates :first_name, :last_name, :profile_name, presence: true
Dillon Carter
Dillon Carter
6,364 Points

It worked! :) I knew it was something simple lol. Thank you for helping me out on this John.