Modified from GDI Seattle Ruby on Rails track.
You can use Cloud9 or Rails "locally" if you already have it installed.
If you're going to use Cloud9, go ahead and sign up for an account.
rails new app
You just created a new Rails app called "app".
You can call it whatever you want!
rails new bananas
^^That creates a new Rails app called "bananas"
The reason Rails got so popular is for "convention over configuration." Rails already comes "pre-configured" with a lot of stuff so you don't have to spend time doing set-up.
This means you have to follow convention.
Good news! There's a lot of documentation and resources.
The downside is — you have to be careful with what you do / move.
For example, you wouldn't want to delete a folder you don't think you're going to use.
For now, you really only want to be concerned with:
The app folder contains, well, the most important elements of your app!
This is where you'll spend most of your time in
The config folder is good for:
Your Rails app is going to need a database to run and store info.
The db folder will have all of the elements of your database.
Also known as MVC
Model: the brains (like a class!)
Controller: dispatcher
View: what the user sees
Model: ingredients of a recipe
Controller: directions of a recipe
View: picture of a recipe
"MVC" is a common "pattern" used in programming and it's what Rails uses.
The Model, View, and Controller all go hand in hand.
rails generate *something*
This is a generator that comes in Rails that helps create necessary files for you.
rake db:migrate
This is always necessecary to generate a database
sqlite3: the default database that comes with Rails
postgresql: more widely used in "real world" apps. You will need to install postgres in order to deploy your app.
There is an extra step with postgres when creating a database. You need to run rake db:create before rake db:migrate
First steps:
Likely you will only do these during project setup.
Ongoing steps:
i.e. you will do these more than once over the course of development:
What we just built is called "CRUD"
CREATE
READ
UPDATE
DELETE
This is the most common type of app.
A blog
Pretty much any app needs basic CRUD
rails generate scaffold *something*
This command generates:
Because it's important to know the underlying factors of how things work.
Now you can spend your time being more productive!
Gems are "packages" in Ruby that do things for you.
There are a lot of gems you can take advantage of.
This is great when you're learning! You can see the gem's source code and see how they implemented the feature.
When choosing a gem, make sure that:
Open your "Gemfile" (located at the root of the app)
gem 'name-of-gem'
Usually, the gem documentation will say how to do this
Run 'bundle install' on the command line to install your gems