Ruby on Rails 3 Day BC

42
Ruby on Rails 3-Day BootCamp

description

NIRD Ruby on Rails 3 day Rails BootCamp

Transcript of Ruby on Rails 3 Day BC

Page 1: Ruby on Rails 3 Day BC

Ruby on Rails3-Day BootCamp

Page 2: Ruby on Rails 3 Day BC

Introductions

Name Coding Experience What would you like to learn?

Page 3: Ruby on Rails 3 Day BC

Curriculum

RoR ToolsetRails Walk-ThroughGems and DeploymentFull Apps and Ruby inside Rails

Page 4: Ruby on Rails 3 Day BC

ScheduleTimes Day 1 Day 2 Day3

9am - 10:30 Tools RubyToolBox BootStrap Break

10:45 - 12 Scaffold and Views Cucumber RailsApps and

Hobo / SpreeLunch

1pm - 2:30 Routes and Controllers Devise Calculator

Break

2:45 - 4:30 Models and Testing I18N and Haml Translator

Page 5: Ruby on Rails 3 Day BC

Learning Goals

Basic RailsCommon Patterns and PracticesWhere to go for help

Page 6: Ruby on Rails 3 Day BC

Learning Path

ExperimentationTest First TeachingAsk QuestionsResources for finding answers

Page 7: Ruby on Rails 3 Day BC

Structure

Explanation (me talking)Demonstration (me typing)Experimentation (in-class coding)Questions

Page 8: Ruby on Rails 3 Day BC

RoR ToolsRVM / Pik / Jewelry Box / Rb.EnvGit / Github / HerokuSublime / Vi / RubyMineRubyGems / RubyToolboxTesting / RSpec / CucumberTerminal / irb / Rails Console

Page 9: Ruby on Rails 3 Day BC

RoR ResourcesRailsGuides - guides.rubyonrails.orgRails API - api.rubyonrails.orgRubyDoc - ruby-doc.orgRailsCasts - railscasts.comGithub ReadMeRuby ToolBox - www.ruby-toolbox.com

Page 10: Ruby on Rails 3 Day BC

Ruby vs. RailsRuby is the Language -

developed 1993 Yukihiro Matsumoto “Matz”

Rails is the Framework - developed 2004 David Heinemeier Hansson “DHH”

Page 11: Ruby on Rails 3 Day BC

The Ruby Way Written in CInfluenced by SmallTalk & PearlRuby is for PeopleMINSWANOSS (Open Source Software)RubyGems

Page 12: Ruby on Rails 3 Day BC

The Rails Way

Opinionated SoftwareConvention over ConfigurationDRY (Don’t Repeat Yourself)TDD (Test Driven Development)Less Code, More Productivity

Page 13: Ruby on Rails 3 Day BC

ToolsCommand LineRuby / RubyGemsRailsSource Control - GitIDEDeployment - Heroku

Page 14: Ruby on Rails 3 Day BC

Command Line

Command Prompt (CLI)Mac: Terminal, iTerm, etc...Unix: bash, zsh, csh, etc....Windows: Command Prompt w/ Ruby on Rails

Page 15: Ruby on Rails 3 Day BC

Ruby

Ruby -v1.9.2, 1.9.3, 2.0.0 (1.8.7)

gem listBundler, Rake, rubygems, etc...

Page 16: Ruby on Rails 3 Day BC

RVMRuby Version Manager

rvm listrvm uservm gemset list

rvm.io

Page 17: Ruby on Rails 3 Day BC

Ruby VersionsMRI, YARV, Standard Library, C-RubyJRuby - JavaRubinius - Pure RubyMagLev - SmallTalkMacRuby - Objective-CIronRuby - C# (for .Net)

Page 18: Ruby on Rails 3 Day BC

Rails

Rails -v2.0-3, 3.0-2, 4.0

Page 19: Ruby on Rails 3 Day BC

RVM DemoGemset for Rails 4

rvm use --create 2.0.0@rails4gem install rails --version 4.0.0.beta1 mkdir rvm_testcd rvm_testrvm --rvmrc --create

Page 20: Ruby on Rails 3 Day BC

Git

which gitgit --version

Page 21: Ruby on Rails 3 Day BC

Git

Source Control SystemTimeline, Track ChangesBranching and MergingCode Safety

Page 22: Ruby on Rails 3 Day BC

Git Commandsgit clone / initgit statusgit add / rmgit commitgit pushgit log

Page 23: Ruby on Rails 3 Day BC

Git Remotes

GitHub - www.github.comHeroku - www.heroku.com

Page 24: Ruby on Rails 3 Day BC

Git Help

Git Site - git-scm.comGit Immersion - gitimmersion.comGitHub Help - help.github.com

Page 25: Ruby on Rails 3 Day BC

Git Demomkdir git_testcd git_testgit inittouch test_file.txtgit statusgit add .git commit -m “add a file”git status

Page 26: Ruby on Rails 3 Day BC

Git Democd ..git clone git_test/.git clone_testcd clone_testlsgit remote -vtouch clone.txtgit commit -am “add another file”git push

Page 27: Ruby on Rails 3 Day BC

Editor

Sublime Text 2 / TextMateRubyMineKomodoEditEclipseVi / Vim / Emacs

Page 28: Ruby on Rails 3 Day BC

Sublime Text 2

Command line aliasWin: doskey subl="C:\Program Files\Sublime Text 2\sublime_text.exe" $*

Mac: ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

Linux: sudo ln -s /opt/SublimeText2/sublime_text /usr/bin/subl

How to Open a folder

Page 29: Ruby on Rails 3 Day BC

BREAK!

10-15 minutes

Page 30: Ruby on Rails 3 Day BC

Rails

New Rails AppModify the HomePageScaffoldMVCLayers

Page 31: Ruby on Rails 3 Day BC

Create a New App

rails Shows Options

rails new <app_name> --options

Page 32: Ruby on Rails 3 Day BC

Create a Class Management App

We want an app to manage Students, Classes, and Teachersrails new class_mngmt

Page 33: Ruby on Rails 3 Day BC

The Application Directory

The Root of our App: Rails rootEntire App in one directory!

Page 34: Ruby on Rails 3 Day BC

Run the App

cd class_mngmtrails

see rails commandsrails server

Page 35: Ruby on Rails 3 Day BC

Save a Baseline with git

git initgit add .git commit -m “add a bare rails app to track changes”

Page 36: Ruby on Rails 3 Day BC

Modify the HomePage

public/index.htmlpublic folder contains static content

Page 37: Ruby on Rails 3 Day BC

Scaffolding

rails generatesee the generators

rails g scaffold Student full_name age:integer bio:text title

Page 38: Ruby on Rails 3 Day BC

MVC

BrowserBrowserRequestRequest

ControllerController

ModelModel

DatabaseDatabase

ViewView

ResponseResponse

Page 39: Ruby on Rails 3 Day BC

Shorten Bio Demo

Shorten the bio on the view pageAdd a read more link

Page 40: Ruby on Rails 3 Day BC

Helpers

Presentation LogicPresenter PatternRuby Module - Included on all viewsMethod DefinitionsHelp generate html

Page 41: Ruby on Rails 3 Day BC

View Exercise

On the main Student pageChange the Listing Students toShow only the Full Name and titleHave the Full Name link to the view pageRemove the view link

Page 42: Ruby on Rails 3 Day BC

Lunch!

12pm - 1pm