- Feel free to tag your tweets with #tslrails
- We live at @starterleague
- 9:30am - 9:45am : Orientation
- 9:45am - 10:15am: Explore static mockup of app / HTML review
- 10:15am - 12:00pm : Dive in to Rails
- 12:00pm - 1:00pm : Break for Lunch
- 1:00pm - 2:30pm : Bring mockup to life with Rails
- 2:30pm - 3:30pm : Add an API
- 2:45pm - 4:00pm : Create admin functionality
- 4:15pm - 5:00pm : Deploy to the web
- 5:00pm - 6:00pm : Reflections and office hours
- If you haven't already, create an account at GitHub. If you have, log in.
- If you haven't already, create an account at Nitrous.io. If you have, log in. Create a free box. Ignore all the upsell prompts. From your Boxes page, choose the box you created and click "IDE".
Load up this Google doc (anonymously, if you'd like) to share feedback & questions. We'll keep an eye on it throughout the day.
- Go to the GitHub repository for our mockup and click the Download Zip button. Unzip.
- Open up
item.html
andnew.html
and look 'em over.
rails new dinner
Create a new appcd dinner
Navigate into your appbundle install
To set up your environemnt, in case this didn't happen automatically.rails server
Start your web server- Visit your app by going to Preview > Port 3000 in the menu bar.
For our purposes, we'll use Item
, but it can be anything.
rails generate scaffold Item title:string description:string link:string image:string category:string
Then, set up the database by runnning this:
rake db:migrate
rails destroy scaffold Item
- Get Started with Heroku
- Open your app's
Gemfile
- Change this:
gem 'sqlite3'
to this:
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
- From the command line,
bundle install
git add -A
Add all of the files in the current folder to a version staging areagit commit -m '[COMMIT MESSAGE OF YOUR CHOICE]'
Describe and save the current version of the codeheroku create APP-NAME
Create a repository for our code in Heroku's cloudgit push heroku master
Send our code to Heroku for deploymentheroku run rake db:migrate
Create any database tables we need on Heroku's serverheroku open
Open our live app
pwd
Display your current locationls
List the contents of the current foldermkdir <folder name>
Create a subfoldercd
Navigate to your Home foldercd <folder name>
Navigate into a subfoldercd ..
Navigate back to the parent folderControl + c
Stop the server, get back to command line
clear
to clear your terminal section
- At the heart of every app is data; things that the app keeps track of, and presents to the user in a valuable way.
- To store all this data, we typically use databases. A database is simply a set of tables.
- We refer to these things as resources. Pretty much every app you can think of is a collection of resources that you can Create, Read, Update, and/or Delete.
- As such, Rails gives us a handy tool to get a head start on building a CRUD resource.
rails generate scaffold <table name (singular)> <first column>:<datatype> <second column>:<datatype> …
Get a headstart on building a database-backed web resourcerake db:migrate
Create the actual table in your database- Open
http://localhost:3000/<table name (plural)>
in Chrome
- Place all CSS files into
app/assets/stylesheets
- Place all JavaScript files into
app/assets/javascripts
- Place all image files into
app/assets/images
- CSS and JavaScript will be automatically included in all of the pages served by the app by default.
- Images can be located at
http://localhost:3000/assets/<filename>
- Delete the
app/stylesheets/scaffolds.css.scss
file.
git clone REPO-URL
Download the code and version historycd REPO-NAME
Navigate into the repositorybundle install
Install all the libraries that the app needsrake db:migrate
Create your database and tablesrake db:seed
Pre-populates database with dummy datarails server
Start the server (don't forget to quit any other running servers with CTRL-C)
- Your HTML templates are located in the
app/views/CONTROLLER-NAME>
folder. - View templates are standard HTML with a bit of Ruby sprinkled in.
- Ruby goes in special Embedded Ruby Tags, <%= %>
- Check out
app/views/projects/show.html.erb
. What's the pattern for accessing data from the database? - Try to enhance the HTML around the ERB to look more like our mockup.
- You need not include
<html>
,<head>
, or<body>
tags in the view template; Rails will automatically include them. Just include the content of the body. - First just paste the static markup into the view template; then try to go through, line by line, and embed Ruby wherever you need to in order to make it dynamic.
- In the controller file, add a line like this:
http_basic_authenticate_with :name => "sxs2", :password => "2014"
on line 2 - This will require authentication for every action in this controller.
Please stay in touch with us; we'd love to see the beautiful things you build.