Hackchange_demo is a project mainly written in RUBY and JAVASCRIPT, it's free.
Hackchange Demo Application
h1. Rails App
Below is a rough set of steps to walk through teaching a beginning course on Rails, Ruby, and web development. The assumption is that the students will have already been through a crash course (a few days) on HTML and CSS. The thinking behind this is that the students will have more fun and be more engaged if they're building something as they're learning.
We start off with the basic Rails steps to give the satisfaction of creating something quickly. The first week and a half is going through some rough Rails concepts. For the last half of the second week we get into some basic programming concepts with Ruby. The idea here is that they've already created something and now we can show them how/what they did. Going forward we'll reference the basic concepts whenever they can be tied back to what is being done in Rails.
We should create labs and hand on assignments whenever possible.
rails new hackchange_demo
cd hackchange_demo
rails s
open browser and look at http://localhost:3000
delete file in public/index.html
comment out root :to => "welcome#index" in routes.rb
rails g controller welcome ** Will generate tests, ignore those for now
create app/views/welcome/index.html.erb
Enter a message (html)
Inserting <%= Time.now %> in ERB
Refresh in browser, see it change!
View page source
Look at Rails server, explain
Simple CSS/Rails styling
h2. Feature: Creating a video
Generate the controller rails g controller videos Question: What is a controller? (request/response cycle) Question: How do we tell the application that the controller exists?
Creating the resource - add a route: resources :videos ** Explain adding a route - tells the app to route requests to that controller and creates helper functions
Add link to create a video Open browser, refresh, click link Explain 'action not found' error message ** Look at Rails server, explain
Add new method in controller - explain error about view not found Explain template not found error message
h2. Modeling videos
What information do we want to store about a video? ** Title Submitter name *** Embed code
What is a database? What is a model?
h2. Create form
Create file app/views/videos/new.html.erb
Write the form
Add link to home
Explain 'root' route
Enter text and submit
Explain action not found, tie to previous time we saw action not found
Look at params in Rails server
Explain or mention HTTP POST
h2. Add create method
Video.create(params[:video])
Submit form
Go to Rails console
Video.all
Redirect to root_path
Submit again, look at Rails server, see what redirect does
h2. Wiring up index
h2. Edit a video
h2. Basic programming concepts (inspired by Ruby in 20 minutes)
h2. Validation
h2. Partials