Boutique product development company
It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
Ruby on Rails - 101
Umair Amjad
http://about.me/umairamjad
Who am I?
Umair Amjad
Technical Lead / SSE
(Bayt.com)
(Confiz Limited)
(AboutUs)
BS CS 2006 (FAST-NU)
MS CS 2012 (FAST-NU)
http://about.me/umairamjad
Why I am here?
What will happen next?
(6 sessions of 4 hours each)
Ruby on Rails 102 (Moderate)
Ruby on Rails 103 (Expert)
Fun with Gems, Authenticating Users, Heroku, Capistrano,
Security/Performance, Tuning, Pagination, Email in Rails, Eager Loading,
Background Tasks, Unit Testing, Internationalization & Localization ...
Ruby on Rails Workshop
Agenda:
• Ruby Language
• Environment Setup
• Overview of RoR
• MVC – ActiveRecord, ActionController, ActionView
• Routing
• Assets/Bundler
• REST Architecture
• DB Migrations
• Console
• ActiveRecord Associations
• Logging
• Validation/Validation Helpers
• Forms/ActionView helpers
• Caching
• Debugging
Why Ruby on Rails?
Why Ruby on Rails?
http://www.payscale.com/research/US/Skill=Ruby_on_Rails/Hourly_Rate
Ruby on Rails - Users
- Amazon (internal)
- Intel (internal)
- HP (internal)
- NASA (internal)
- Twitter (in early age)
- Basecamp
- Slideshare
- Pakwheels
- Github
- YellowPages
Ruby on Rails – (few) Practitioner in Pakistan
- Confiz Limited
- Nextbridge
- Arbisoft
- Tkxel
- PITB
- Kwanso
- 7vals
- Venexel
…..
Nice-to-Have
- Basics of Linux
- Basic knowledge of HTML, CSS, JS
- Databases Relations
- Frameworks
- Client Server Architecture
- HTTP methods
- MVC (Model View Controller)
- ORM (Object-relational mapping)
- Cloud Computing
Ruby
Primary:
http://www.tutorialspoint.com/ruby/index.htm
The Little Book Of Ruby
References:
http://www.codecademy.com/tracks/ruby
http://www.rubyist.net/~slagell/ruby/getstarted.html
http://rubymonk.com/learning/books/1-ruby-primer
Try Ruby online:
http://www.compileonline.com/execute_ruby_online.php
Environment
Setup
(RVM)
http://setuprubyonrails.blogspot.com/2012/04/ruby-on-rails-environment-setup-on.html
https://gorails.com/setup/ubuntu/14.10
rvm install [ruby_version]
rvm install 1.9.2
rvm use [ruby_version]
rvm use 1.9.2
rvm gemset create [gemset_name]
rvm gemset create rails3.1.3
rvm use [ruby_version]@[gemset_name]
rvm use 1.9.2@rails3.1.3
Overview of
RoR / MVC
REST
Architecture
Assets
/
Minification
Bundler
Code
Generation
Rails
Rake, Route, Controller, Model, View
Rake
Rake is Ruby make, a make-like language written in Ruby.
Rails uses Rake extensively, especially for the innumerable little
administrative tasks necessary when developing database-
backed web applications.
Rake tasks are loaded from the file Rakefile
Rails rake tasks live under /lib/tasks
You can put your own tasks under lib/tasks
bundle exec rake -T
bundle exec rake -T db #See a list of database tasks
db: Database
The most common tasks of the db: Rake namespace are migrate
and create, and it will pay off to try out all of the migration rake tasks
(up, down, redo, reset). rake db:version is useful when
troubleshooting, telling you the current version of the database.
rails: Rails-specific tasks
After upgrading Rails, it is useful to run rails:update, which will
update your config and scripts directories, and upgrade your Rails-
specific javascript
rake stats #gives summary statistics about your code
rake routes #lists all your defined routes
rake secret
Routes
Controllers
Model
Views
Debugging
/
Error Handling
gem install debugger
class PeopleController < ApplicationController
def new
debugger
@person = Person.new
end
end
$ rails server --debugger
=> Booting WEBrick
=> Rails 4.0.0 application starting on http://0.0.0.0:3000
=> Debugger enabled
Caching
Console
rails console
The console command lets you interact with your Rails application from
the command line. On the underside, rails console uses IRB, so if you've
ever used it, you'll be right at home. This is useful for testing out quick
ideas with code and changing data server-side without touching the
website.
rails dbconsole
rails dbconsole figures out which database you're using and drops you
into whichever command line interface you would use with it (and figures
out the command line parameters to give to it, too!). It supports MySQL,
PostgreSQL, SQLite and SQLite3.
Questions ?

Ruby on Rails workshop for beginner

  • 1.
    Boutique product developmentcompany It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products. Ruby on Rails - 101 Umair Amjad http://about.me/umairamjad
  • 2.
    Who am I? UmairAmjad Technical Lead / SSE (Bayt.com) (Confiz Limited) (AboutUs) BS CS 2006 (FAST-NU) MS CS 2012 (FAST-NU) http://about.me/umairamjad
  • 3.
    Why I amhere?
  • 4.
    What will happennext? (6 sessions of 4 hours each) Ruby on Rails 102 (Moderate) Ruby on Rails 103 (Expert) Fun with Gems, Authenticating Users, Heroku, Capistrano, Security/Performance, Tuning, Pagination, Email in Rails, Eager Loading, Background Tasks, Unit Testing, Internationalization & Localization ...
  • 5.
    Ruby on RailsWorkshop Agenda: • Ruby Language • Environment Setup • Overview of RoR • MVC – ActiveRecord, ActionController, ActionView • Routing • Assets/Bundler • REST Architecture • DB Migrations • Console • ActiveRecord Associations • Logging • Validation/Validation Helpers • Forms/ActionView helpers • Caching • Debugging
  • 6.
  • 7.
    Why Ruby onRails? http://www.payscale.com/research/US/Skill=Ruby_on_Rails/Hourly_Rate
  • 8.
    Ruby on Rails- Users - Amazon (internal) - Intel (internal) - HP (internal) - NASA (internal) - Twitter (in early age) - Basecamp - Slideshare - Pakwheels - Github - YellowPages
  • 9.
    Ruby on Rails– (few) Practitioner in Pakistan - Confiz Limited - Nextbridge - Arbisoft - Tkxel - PITB - Kwanso - 7vals - Venexel …..
  • 10.
    Nice-to-Have - Basics ofLinux - Basic knowledge of HTML, CSS, JS - Databases Relations - Frameworks - Client Server Architecture - HTTP methods - MVC (Model View Controller) - ORM (Object-relational mapping) - Cloud Computing
  • 11.
  • 21.
    Primary: http://www.tutorialspoint.com/ruby/index.htm The Little BookOf Ruby References: http://www.codecademy.com/tracks/ruby http://www.rubyist.net/~slagell/ruby/getstarted.html http://rubymonk.com/learning/books/1-ruby-primer Try Ruby online: http://www.compileonline.com/execute_ruby_online.php
  • 22.
  • 23.
    http://setuprubyonrails.blogspot.com/2012/04/ruby-on-rails-environment-setup-on.html https://gorails.com/setup/ubuntu/14.10 rvm install [ruby_version] rvminstall 1.9.2 rvm use [ruby_version] rvm use 1.9.2 rvm gemset create [gemset_name] rvm gemset create rails3.1.3 rvm use [ruby_version]@[gemset_name] rvm use 1.9.2@rails3.1.3
  • 24.
  • 33.
  • 37.
  • 39.
  • 41.
  • 45.
  • 46.
  • 47.
    Rake is Rubymake, a make-like language written in Ruby. Rails uses Rake extensively, especially for the innumerable little administrative tasks necessary when developing database- backed web applications. Rake tasks are loaded from the file Rakefile Rails rake tasks live under /lib/tasks You can put your own tasks under lib/tasks bundle exec rake -T bundle exec rake -T db #See a list of database tasks
  • 48.
    db: Database The mostcommon tasks of the db: Rake namespace are migrate and create, and it will pay off to try out all of the migration rake tasks (up, down, redo, reset). rake db:version is useful when troubleshooting, telling you the current version of the database. rails: Rails-specific tasks After upgrading Rails, it is useful to run rails:update, which will update your config and scripts directories, and upgrade your Rails- specific javascript rake stats #gives summary statistics about your code rake routes #lists all your defined routes rake secret
  • 49.
  • 55.
  • 65.
  • 86.
  • 98.
  • 101.
    gem install debugger classPeopleController < ApplicationController def new debugger @person = Person.new end end $ rails server --debugger => Booting WEBrick => Rails 4.0.0 application starting on http://0.0.0.0:3000 => Debugger enabled
  • 102.
  • 106.
  • 107.
    rails console The consolecommand lets you interact with your Rails application from the command line. On the underside, rails console uses IRB, so if you've ever used it, you'll be right at home. This is useful for testing out quick ideas with code and changing data server-side without touching the website. rails dbconsole rails dbconsole figures out which database you're using and drops you into whichever command line interface you would use with it (and figures out the command line parameters to give to it, too!). It supports MySQL, PostgreSQL, SQLite and SQLite3.
  • 109.