Giter Club home page Giter Club logo

activerecord-validations-readme's People

Contributors

annjohn avatar aviflombaum avatar changemewtf avatar gj avatar hellorupa avatar ihollander avatar jmburges avatar lizbur10 avatar maxwellbenton avatar mnrd-brian avatar sylwiavargas avatar tracypholmes avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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]

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

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."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.