Ruby Flashcards

1
Q

3 principles underlying Ruby mechanisms:

A

1- Everything is an object
2- Every operation is a method call on some object and returns a value
3- All programming is metaprogramming

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is metaprogramming?

A

Classes and methods can be added or changed at any time, even while a program is running

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is Ruby interpreted or compiled?

A

Compiled

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

migrations

A

-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

routing

A

-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

embedded Ruby

A

-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What kind of a site is Twitter

A

social media microblogging site

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the built-in testing site in Ruby?

A

Mini Test

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

External dependencies (add-ins)

A
  • RSpec
  • Cucumber
  • Capybara
  • Factory Girl
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

mockups

A

-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is Ruby scaffolding?

A
  • automatically creates code to model data and interact with it through the web
  • scaffolding is good for getting started quickly
  • not good for understanding
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

URI

A

-Uniform Resource Identifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

URL

A

-Uniform resource locator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is Ruby on Rails

A
  • 100% open source
  • available under MIT license
  • a domain specific language for writing web applications
  • makes common web programming tasks - such as generating HTML, making data models, routing URLs -easy
  • adapts rapidly to new developments in web technology and frameworks
  • first framework to fully digest REST
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

gem

A

-self-contained solutions to specific problems such as pagination and image uploade

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

the default Rails testing framework

A

MiniTest

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Ruby books

A
  • Learn to Program by Chris Pine
  • Beginning Ruby by Peter Cooper
  • Learn Ruby on Rails by Daniel Kehoe
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Resources for intermediate to advanced Ruby

A
  • Code School
  • The Turing School of Software & Design (Denver)
  • Tealeaf Academy (online)
  • Thinkful
  • Pragmatic Studio: Online Ruby and Rails courses
  • RailsCasts by Ryan Bates
  • RailsApps
  • Rails guides
  • http://www.railstutorial.org/#help
  • [Bk] Conquering the Command Line by Mark Bates
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

website for “how to install rails”

A

InstallRails.com

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

RubyGems

A

-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

3 essential components needed to install web applications

A

1-a text editor
2-a file system navigator
3-a command-line terminal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

a global search that is essential to navigating any large Roby or Rails project

A

“Find in Files” global search

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

universal indentation convention in Rugy

A

-using two spaces for indenting

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How do you create a new Rails application?

A
  • rails new

- creates a skeleton rails application in whatever directory you are in

25
Q

command line

A

-one of the most powerful tools in the developer’s toolbox

26
Q

What does “rails new” do?

A
  • Creates the standard directory and file structure common to all Rails apps
  • automatically runs the bundle install command after the file creation is done
27
Q

How do you change the default application gems?

A

-Open the Gemfile with a text editor

28
Q

gem: uglifier

A

handles file compression for the asset pipeline

29
Q

What command do you use to install only the latest gem

A

> =

-see Ruby tutorial p. 20

30
Q

how do you install gems?

A
  • Update the Gemfile with the gems you want to use

- $ bundle install

31
Q

How does Cloud9 assign the IP address and port number dynamically to run a web server?

A

-using the special environment variables $IP and $PORT

$ rails server -b $IP -p $PORT

32
Q

How do you generate a rails scaffolding?

A

-pass the scaffold command to the rails generate script
-the argument of the scaffold command is the singular version of the resource name (ex. User) along with optional parameters for the data model’s attributes
$ rails generate scaffold User name:string email:string
-id does not have to be added. It is created automatically by Rails for use as the primary key in the database.

tutorial p. 56

33
Q

What is Rake?

A

-the Ruby version of Make
-a make-like language written in Ruby
-

34
Q

How do you migrate the database using Rake?

A

$ bundle exec rake db:migrate

  • updates the database with our new Users data model.
  • we run Rake using bundle exec to ensure that the command user the version of Rake corresponding to our Gemfile.
35
Q

REST

A
  • Representational State Transfer
  • an architectural style
  • most application components are modeled as resources that can be created, read, updated, and deleted
  • corresponding to the HTTP request methods: Post, Get, Patch, Delete
  • helps you make choices about which controllers and actions to write by structuring the application using resources that get created, read, updated, and deleted
36
Q

instance variables

A
  • start with @

- these variables are automatically available in the views

37
Q

console

A

-useful tool for interacting with Rails applications

$ rails console

38
Q

The base class for controllers provided by the Rails library Action PackA

A
  • ActionController::Base
  • ApplicationController inherits from ActionController::Base
  • All Rails controllers inherit from ApplicationController
39
Q

Patch

A
  • used for data updates

- used to be “push”

40
Q

Controller action

A

-defined inside controllers

41
Q

How do you see a list of current controllers?

A

$ ls app/controllers/*_controller.rb

42
Q

root route

A
  • determines the page that is served on the root URL
  • because the root URL is the URL for an address where nothing comes after the final slash, it is often referred to as “slash”
  • you can structure the root route with the command root in the routes.rb file in the config directory
  • root ‘application#hello’ tells it to go to the hello controller action in the controller called application
43
Q

rails router

A

-sits in front of the controller and determines where to send requests that come in from the browser

44
Q

root route

A

-determines the page that is served on the root URL

45
Q

root URL

A

-referred to as slash because nothing comes after the slash

46
Q

How do you tell the application where to route the root?

A

use the root command with the controller name followed by # and then the action within that controller
$ root ‘welcome#index

47
Q

resource

A

a combination of the data model and the user interface to update it

-tutorial p. ?

48
Q

How do you generate rails scaffolding?

A

Pass the scaffold command to the rails generate script.

49
Q

What are the arguments of the scaffold command?

A

The singular version of the resource name (such as ‘user’) together with optional parameters for the data model’s attributes

50
Q

naming convention for models and controllers

A
  • models are singular (such as “user”)

- resources and controllers are plural

51
Q

what is the primary key in a rails table?

A

-id (which is created automatically by rails)

52
Q

what is meant by “migrate” the database and how is it done?

A

-update the database with a new model
-it is done using rake
$ bundle exec rake db:migrate

Rake is run using bundle exec in order to ensure that the command uses the version of Rake corresponding to our gemfile

53
Q

How do you run the rails server?

A

$ rails server -b $IP -P $PORT

use only “rails server” if running locally

54
Q

What is the console? and how do you invoke it?

A

-a useful tool for interacting with rails apps
$ rails console

> > exit
to exit the console
or CNTRL-d

55
Q

What is the base class for models provided by Active Record?

A

ActiveRecord::Base
our model objects inherit from ActiveRecord::Base to gain the ability to communicate with the database, treat the database columns as Ruby attributes, etc

56
Q

How do you search file names?

A

GoTo Anything command

57
Q

what does
$ rails server
do?

A

a Rails command-line program (or script)
that runs a local web server to assist in application development

for cloud 9 us
$ rails server -b $IP -p $PORT

58
Q

What is the root route?

A

It is the default action that is invoked by the root URL (or slash)

59
Q

what is the format for a route?

A

controllerName#controllerActionName
ex: root ‘application#index’
where the controller is “welcome” and the action is “index”