2. Active Record Migrations Flashcards
Migrations
are a convenient way to alter your database schema over time in a consistent and easy way.They use a Ruby DSL so that you don’t have to write SQL by hand, allowing your schema and changes to be database independent.
each migration as being a new ‘version’ of the database.
link_to method
is one of Rails’ built-in view helpers. It creates a hyperlink based on text to display and where to go. Rails will use the current controller by default.
ActiveRecord::Base.
Active Record supplies a great deal of functionality to your Rails models for free, including basic database CRUD (Create, Read, Update, Destroy) operations, data validation, as well as sophisticated search support and the ability to relate multiple models to one another.
Validations (in model from ActiveRecord)
Rails can validate a variety of conditions in a model, including the presence or uniqueness of columns, their format, and the existence of associated objects.
render vs redirect_to
This rendering is done within the same request as the form submission, whereas the redirect_to will tell the browser to issue another request.
errors message from failing save
<div> <h2> prohibited this article from being saved: </h2> <ul>
<li> </li></ul> </div>
pluralize
rails helper that takes a number and a string as its arguments. If the number is greater than one, the string will be automatically pluralized.
field_with_errors.
Rails automatically wraps fields that contain an error with a div with class field_with_errors. You can define a css rule to make them standout.