activerecord-validations-readme's Issues
record.errors[:name] should be record.errors[:email]
At the bottom of the ActiveRecord Validations readme there is an example defining a custom validation. If there is an error in the description it says you should push an error message into record.errors[:attribute] e.g. record.errors[:email] but directly below that there is the text "The result of these steps should be the following:"
class EmailValidator < ActiveModel::Validator
def validate(record)
unless record.email.match?(/flatironschool.com/)
record.errors[:name] << "We're only allowed to have people who work for the
company in the database!"
end
end
end
--
In this example on line 4 it references record.errors[:name] not record.errors[:email]
End of the lesson goes from 0 to 100 real quick
The Custom Validators section is confusingly written. The linked Rails guide is a much better resource.
Custom Validators section should be it's own lesson
This portion of the lesson is not well-explained and really should be it's own lesson. Also, consider only teaching #validate for custom validations.
confusing terminology
"We can use ActiveRecord::Base class methods like #validates to set things up."
#validates is not a class method. I think it meant to say,
"We can use ActiveRecord::Base instance methods like #validates available to our classes to set things up."
Needs more explanation?
Apologies if this is not the right forum/form to make this comment in, but I think the section on custom validations needs a little more meat on the bones. Maybe a few examples? I realize the curriculum's huge and this is probably a minor sub-topic, but I definitely don't understand when to use each custom validator option or even where to build the class for a custom validator (in a separate .rb file in the models folder??). I was able to get through the subsequent lab through trial & error, but I think a little more explanation would be really helpful here! Also, I of course used the http://guides.rubyonrails.org/active_record_validations.html site, but I didn't find their explanation any more helpful than what we have here. Thanks!
typo
"If your validation needs become more complex, consult the documentation."
...needs TO become more complex
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.