Last active
April 30, 2019 19:55
-
-
Save Alacrity01/acb00e7aea12b03f9567cf04918171c4 to your computer and use it in GitHub Desktop.
Week 2, Day 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Week 2, Day 2 | |
Main subject: Rails | |
Rails is a framework for Ruby that is designed for building websites faster. | |
Ruby was made in 1995 by Someone Matsumoto. A man named David Henemeier Hansson (github.com/dhh <-- He goes by DHH) built Rails in 2005. (He did not create github. Github does run off of Rails, however.) Hulu, AirBnB, and some other famous applications all run on Rails. | |
"If anyone tells you that Rails does not do big applications, they are lying." -Josh Nixon, circa 2019 | |
You can build APIs with the Rails framework. | |
iPhone apps usually use a SQL Lite database to build. | |
rails new sample_app <-- terminal command that saves us about 7 hours--builds folders and files necessary for making a web application. Builds about 150 files and folders. | |
rails generate controller api/example_pages | |
rake db:create | |
rails server | |
MEMORIZE THIS! | |
▼ ▼ ▼ ▼ STEPS ▼ ▼ ▼ ▼ | |
--------------------- | |
1. WEB REQUEST rails new sample_app | |
2. API ROUTE <--MEMORIZE THESE STEPS | |
3. API CONTROLLER | |
4. WEB RESPONSE | |
=> <-"hashrocket" | |
A method inside a controller is called an action. | |
You must have a line that says render at the bottom of your action. | |
Controllers must always have a plural name. Rails has its own dictionary and can translate between singular and plural. It will recognize unique plurals, like alumni and curricula. | |
rails new sample_app | |
cd sample_app | |
rails generate controller api/example_pages | |
rake db:create | |
rails server | |
Methods in the controller file are called actions. | |
api is a folder in controllers folder | |
routes is a folder in config folder | |
rails server <--starts the server | |
Control + c in the terminal stops the server. | |
.shuffle! <- will shuffle an array | |
sample_array = [1..60] <--creates an array with values 1 through 60 (including 60) | |
sample_array = ["a".."z"] <--creates an array with values a through z | |
sample_array.sample(6) will take a sample of 6 values from an array titled "sample_array" | |
.join <--turns an array into a string | |
"template means view" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment