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
Anthony Ross
2,756 PointsDevise Validation Issues
Hi Everyone,
Happy New Year! I have been following along with the Ruby guide 'build a simple ruby on rails application'. It's been great, I've learned a lot!
That said, I'm afraid that the video is out of date with a few of the gems I'm using and it's causing some issues with devise that I can't seem to get my head around. I can log in, but the validation on the sign-up/register page won't work anymore. It's constantly saying invalid fields (from 5-7 errors) no matter what I try. I've reviewed the devise documentation but unsure what's wrong here.
I don't know if posting my code for one specific example is helpful so I've linked the repository below. Any help is hugely appreciated as I am stuck!
https://github.com/allcentury/treebook
Anthony
1 Answer
Charles Massry
12,253 PointsI'm not sure if this will work but this works for me and yours is a little different:
In your user model our regular expressions for profile_name are a little different for profile name my regular expression is
validates :profile_name, presence: true,
uniqueness: true,
format: {
:with => /^[a-zA-Z0-9_-]+$/,
message: 'Must be formatted correctly.'
}