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
command line
-one of the most powerful tools in the developer's toolbox
26
What does "rails new" do?
- 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
How do you change the default application gems?
-Open the Gemfile with a text editor
28
gem: uglifier
handles file compression for the asset pipeline
29
What command do you use to install only the latest gem
>= | -see Ruby tutorial p. 20
30
how do you install gems?
- Update the Gemfile with the gems you want to use | - $ bundle install
31
How does Cloud9 assign the IP address and port number dynamically to run a web server?
-using the special environment variables $IP and $PORT | $ rails server -b $IP -p $PORT
32
How do you generate a rails scaffolding?
-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
What is Rake?
-the Ruby version of Make -a make-like language written in Ruby -
34
How do you migrate the database using Rake?
$ 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
REST
- 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
instance variables
- start with @ | - these variables are automatically available in the views
37
console
-useful tool for interacting with Rails applications | $ rails console
38
The base class for controllers provided by the Rails library Action PackA
- ActionController::Base - ApplicationController inherits from ActionController::Base - All Rails controllers inherit from ApplicationController
39
Patch
- used for data updates | - used to be "push"
40
Controller action
-defined inside controllers
41
How do you see a list of current controllers?
$ ls app/controllers/*_controller.rb
42
root route
- 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
rails router
-sits in front of the controller and determines where to send requests that come in from the browser
44
root route
-determines the page that is served on the root URL
45
root URL
-referred to as slash because nothing comes after the slash
46
How do you tell the application where to route the root?
use the root command with the controller name followed by # and then the action within that controller $ root 'welcome#index
47
resource
a combination of the data model and the user interface to update it -tutorial p. ?
48
How do you generate rails scaffolding?
Pass the scaffold command to the rails generate script.
49
What are the arguments of the scaffold command?
The singular version of the resource name (such as 'user') together with optional parameters for the data model's attributes
50
naming convention for models and controllers
- models are singular (such as "user") | - resources and controllers are plural
51
what is the primary key in a rails table?
-id (which is created automatically by rails)
52
what is meant by "migrate" the database and how is it done?
-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
How do you run the rails server?
$ rails server -b $IP -P $PORT use only "rails server" if running locally
54
What is the console? and how do you invoke it?
-a useful tool for interacting with rails apps $ rails console >>exit to exit the console or CNTRL-d
55
What is the base class for models provided by Active Record?
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
How do you search file names?
GoTo Anything command
57
what does $ rails server do?
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
What is the root route?
It is the default action that is invoked by the root URL (or slash)
59
what is the format for a route?
controllerName#controllerActionName ex: root 'application#index' where the controller is "welcome" and the action is "index"