Ruby / Rails Flashcards ionicons-v5-c

IRB

Interactive Ruby Shell (IRB). IRB allows us to immediately execute Ruby commands on the fly.

ruby

The ruby command invokes the Ruby interpreter to run Ruby programs from the command line.

Models

Models provide an interface for getting and setting data.

RSpec

RSpec is a behavior-driven development (BDD) framework for the Ruby programming language.

Test-Driven development (TDD)

Test-Driven development (TDD) is a software development process that relies on the repetition of a very short development cycle. First we write a failing test case. Then we produce the minimum amount of code to pass the test. Finally, we refactor the new code.

Controllers

Controllers process user input, update the model, and presents model information.

Standard input

Standard input is data going into a program. By default standard input is expected from the same keyboard which started the program.

case statement operator

Ruby's case statement operator is used to manage more complicated control flow. It can be used as a cleaner alternative to multiple if statements.

begin and rescue

begin and rescue blocks are Ruby's implementation of try/catch blocks in other languages. Exception handling is a very important part of any programming language and allows your program to dynamically rebound from any sort of unexpected error that gets raised during execution. begin/rescue blocks should not be abused. They should only be used when we know that there is a chance that a particular exception may occur.

View

A View "requests information from the model that it uses to generate an output representation to the user" in MVC. In Address Bloc, the command line menu we built operates as our View in the MVC pattern.

rails new

rails new creates a new Rails application with the entire default Rails directory structure.

README

A README is a text file commonly distributed with a program. It contains information that describes what the program does, provides directions on how to install it, run tests, or anything else that another developer would need to know.

asset pipeline

The asset pipeline provides a framework to concatenate and minify, or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, Sass, and ERB.

rails server

The rails server command launches a small web server named WEBrick, which comes bundled with Ruby.

Heroku

Heroku (pronounced her-OH-koo) is a platform-as-a-service (PaaS) that enables developers to build and run applications entirely in the cloud.

Gems

Gems are Ruby libraries that can be used to extend or modify functionality within a Ruby application.

Rails environments

Rails ships with three environments: "Development", "Test", and "Production". These environments are used to tell your app to behave differently in different circumstances, primarily by setting different configuration options and variables.

MVC

MVC (Model-view-controller) is an architectural pattern that divides a given application into three interconnected parts with distinct responsibilities.

Git branching

Diverges the master branch, so that you can work on new features without affecting the master branch. Git branches require little memory or disk space, making branching operations nearly instantaneous.

rails generate

The rails generate command creates controllers from templates. The generate command can also generate controller actions and their corresponding views.

Controllers

Controllers are represented by the C in MVC. Controllers process requests and produce the appropriate output. Controllers communicate with the database and perform CRUD actions where necessary, via models.

Views

Views are responsible for rendering templates. View templates are written using embedded Ruby in tags and integrated with HTML.

rake routes

The rake routes command lists all routes, in the same order as routes.rb.

localhost

localhost is a hostname that represents "this computer".

RSpec

RSpec is a test framework written in and for Ruby.

Rails test database

Rails' dedicated test database allows developers to initiate and interact with test data in isolation so that production data is not compromised.

Test-Driven Development (TDD)

Test-Driven Development (TDD) is a software development process where test code is written prior to production code.

Active Record Models

Active Record Models are the layer responsible for representing business data and logic. They facilitate the creation and use of objects whose data requires persistent storage to the database.

rails generate

The rails generate command uses templates to create models, controllers, mailers, and more. When used to generate a model, it creates the Ruby class, test spec, and Active Record database migration.

Active Record Migrations

Active Record Migrations allow you to evolve your database schema over time. They use Ruby so that you don't have to write SQL by hand.

Rails console

Provides command line access to a Rails application and Ruby.

SQL

SQL is a language for communicating with a relational database.

Object-Relational Mapping

Object-Relational Mapping (ORM) is a design pattern that connects the objects of an application to tables in a database. Using ORM, the properties and relationships of objects in an application can be connected to a database without the need to write SQL statements.

ActiveRecord

ActiveRecord is Rails' ORM library.

Module

A module is independent code that contains everything necessary to implement only one feature.

Seeding data

Rails' seeding feature allows the database to be populated with initial data based on the contents of seeds.rb.

CREATE

POST - create

READ

GET - new/show/index/edit

UPDATE

PUT / PATCH - update

DELETE

DELETE - destroy

rails generate

The rails generate command creates controllers from templates. The generate command can also generate controller actions and their corresponding views.

Resourceful Routing

Rails' resource routing permits the declaration of common routes for a controller. It allows you to declare the routes for the "index", "show", "new", "edit", "create", "update" and "destroy" actions in a single line of code.

rake routes

The rake routes command lists all routes, in the same order as routes.rb.

HTTP Request Methods

HTTP defines methods (verbs) to indicate the desired action to be performed on the identified resource.

HTTP Status Codes

Status codes are numbers returned by HTTP which indicate the result of a request.

Form helpers

Form helpers are view helper methods that generate HTML markup for input forms.

form_for

The form_for method is a form helper which binds a form to a model object.

params

The Rails params hash is available in controllers and contains both query string paramaters and POST data.

ActionDispatch::Flash

ActionDispatch::Flash provides a data structure to pass temporary primitive types (String, Array, Hash) between controller actions. Anything placed in the flash param will be exposed to the next action and then removed. It is commonly used for notices and alerts.

HTTP DELETE request

The HTTP DELETE request is used to remove the identified resource from the web server.