Tag: ruby on rails tutorial: learn web development with rails pdf

Using reversible in Ruby

A complex migration may involve processes that Active Record does not know how to reverse. You can use reversible to specify what to do when a migration is run and when it needs to be rolled back. For example: class ExampleMigration < ActiveRecord::Migration   def change     create_table :distributors do |t|       t.string :zipcode     […]

Validations in Ruby

Active Record allows you to check the state of a model before it is written to the database. There are several methods that can be used to check your models and validate that an attribute’s value is non-empty, unique (not existing in the database), conforms to a certain format, and many more. Validation is a […]