1. Getting Started with Rails Flashcards
What is Rails?
Rails is a web application development framework written in the Ruby language. Two major guiding principles: 1. don’t Repeat Yourself and 2. convention and over configuration:
What is Rails?
Rails is a web application development framework written in the Ruby language. Two major guiding principles: 1. don’t Repeat Yourself and 2. convention and over configuration:
controller’s purpose
to receive specific requests for the application.
view’s purpose
display this information in a human readable format. view templates are written in a language called eRuby (Embedded Ruby)
routing file
which holds entries in a special DSL (domain-specific language) that tells Rails how to connect incoming requests to controllers and actions
resource
is the term used for a collection of similar objects, such as articles, people or animals. You can create, read, update and destroy items for a resource and these operations are referred to as CRUD operations.
resources method
can be used to declare a standard REST resource.
controller
is simply a class that is defined to inherit from ApplicationController. It’s inside this class that you’ll define methods that will become the actions for this controller. These actions will perform CRUD operations on the articles within our system. define an action inside a controller, all you need to do is to define a new method inside the controller.
:formats in error message
specifies the format of template to be served in response. The default format is :html, and so Rails is looking for an HTML template.
key, :handlers in error message
is telling us what template handlers could be used to render our template. :erb is most commonly used for HTML templates, :builder is used for XML templates, and :coffee uses CoffeeScript to build JavaScript templates.
form_for
is a use a form builder. primary form builder for Rails is provided by a helper method called form_for.
<br>
When you call form_for, you pass it an identifying object for this form. In this case, it’s the symbol :article. FormBuilder object - represented by f - is used to build the form.
form_for : pass :url option
params method i
is the object which represents the parameters (or fields) coming in from the form. The params method returns an ActiveSupport::HashWithIndifferentAccess object, which allows you to access the keys of the hash using either strings or symbols.
Models
in Rails use a singular name, and their corresponding database tables use a plural name.
Migrations
are Ruby classes that are designed to make it simple to create and modify database tables.
Rails uses rake commands to run migrations, and it’s possible to undo a migration after it’s been applied to your database. Migration filenames include a timestamp to ensure that they’re processed in the order that they were created.