Basic Code Academy Flashcards
What is ruby?
A programming language
To print something on the computer
Puts
What is rails?
Rails is framework to build Webb apps. Like the frames of a house already in place so one can focusing on building the details.
What is an web app?
Any software that runs in a web browser
name 5 objects
Strings Numbers Booleans Arrays Hashes
Name three types of methods
Methods
Loops
Control flow
Name three types of classes
Classes
Attributes
Instance variables
What are strings
Words or numbers between quotes
What are numbers (object)
Numbers. Ruby has two types, floats: numbers with decimals like 4.3. And integers: whole numbers, either positive or negative like 75 or -10.
What are booleans
True or false statements. 1==1 is true. 1==5 is a false statement.
How is a variable with strings declared?
a = "apple". a = "12"
How is a variable with numbers object declared?
A = 12 A = 12.5 A = 22 + 12.5
How is a variable with booleans declared? True and false
A = (1 == 1) A = (1 == 6)
True
False
What is arrays?
An object. Its a list of objects too.
How is an array created?
By declaring array name and listing the objects between brackets:
A = [“Sebastian”, “Jonas”, “Lisa”]
What is an object in an array list called?
An element
How is an element in an array accessed?
Array name and the index number:
Puts a[0]
=> “Sebastian”
What are hashes?
An object. Helps store information as pairs, key and value.
How are hashes declared?
Menu = {“pizza” => 14.00, “soda” => 2.00, “pasta” => 8.00}
What type of object is declared? Which is key and which is value?
Menu = {“pizza” => 14.00, “soda” => 2.00, “pasta” => 8.00}
Menu hash
The foods key
The prices value
How is the value of a key in a hash object accessed?
From
Menu = {“pizza” => 14.00, “soda” => 2.00, “pasta” => 8.00}
Menu[“pasta”]
Result
=> 8.00
What is a variable?
They are used to store objects so we can access them again. Any object can be stored as a variable.
What’s the terminal command to list the content of the current directory?
ls
What’s the terminal command to list the content of the current directory, including hidden files?
ls -a
How is got configured on a new computer?
git config –global user.name “your name”
git config –global user.email “email”
How is git setup for a new project?
Go to folder in terminal.
git init
How is a project saved to git?
git status //shows what files you’re tracking
git add . //stage
git commit -am “a name for personal reference”
How can you get back something you shouldn’t have deleted with git?
git add .
git checkout -f
What’s the terminal command to see where you are?
pwd
how do you check your rails version?
rails -v
How do you create a new rails application?
rails new examplename
cd examplename
How do you run the rails server?
rails server
What are the four steps to upload changes to github?
Git status
Git add .
Git commit -am “ref name”
Git push
How can u move straight to desktop folder from anywhere, through the terminal?
cd ~/desktop
How do you create a new page?
Rails generate controller pages home
Where is the default url location of a newly created page?
Localhost:3000/pages/pagename
Where do you update the text on your page?
App/views/pages/pagename.html.erb
In what file do you handle directs of visitors?
Config/routes.rb
How can you change the default location of the home page from localhost:3000/pages/home to localhost:3000 (root)
Go to config/routes.rb Replace get "pages/home" With Root "pages#home"
How do you create a page manually?
- Go to app-controllers:pages_controller.rb
Add:
def name of page
end
- Go to app-views-pages.
Create a new file: name of page.html.erb - Go to config:routes.rb
Add: get “pages/sebastian”