• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Web Development with Ruby on Rails, MyGOSSCON 2007
 

Web Development with Ruby on Rails, MyGOSSCON 2007

on

  • 7,196 views

I prepared these slides for my talk at the Malaysian Government OSS Conference 2007 at the Putrajaya International Convention Center from 6-7th December. It's not comprehensive, more meant to whet the ...

I prepared these slides for my talk at the Malaysian Government OSS Conference 2007 at the Putrajaya International Convention Center from 6-7th December. It's not comprehensive, more meant to whet the appetite of people new to it. The examples are very Rails 1.2.x-ish because it's not worth explaining REST yet :)

Statistics

Views

Total Views
7,196
Views on SlideShare
7,126
Embed Views
70

Actions

Likes
1
Downloads
184
Comments
2

4 Embeds 70

http://blog.bitfluent.com 66
http://www.workingwithrails.com 2
http://wildfire.gigya.com 1
http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • You have upload a good intro and have done some good research. thanks
    ---------------------------------
    www.intelegencia.com
    Are you sure you want to
    Your message goes here
    Processing…
  • great intro... thanks<br /><br/>
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Web Development with Ruby on Rails, MyGOSSCON 2007 Web Development with Ruby on Rails, MyGOSSCON 2007 Presentation Transcript

    • Web Development with Ruby on Rails MyGOSSCON 2007 Kamal Fariz Mahyuddin RSB
    • A full-stack framework for developing database-backed web applications according to the Model-View-Controller pattern.
    • A full-stack framework for developing database-backed web applications according to the Model-View-Controller A bunch of stuff that makes web developers happy! pattern. - David Heinemeier Hansson http://flickr.com/photos/pragdave/174964316/
    • 2004 6 7 5
    • > 1 million downloads
    • Hundreds of plugins
    • ~10k people on rubyonrails-talk
    • DB2 SybaseASA Informix Firebird MySQL SQLite Oracle PostgreSQL SQL Server
    • Ruby on Rails Model-View-Controller
    • MVC is like a bakery shop.
    • ActionController Model-View-Controller
    • ActiveRecord Model-View-Controller
    • ActionView Model-View-Controller
    • ActiveRecord Model-View-Controller
    • class Department < ActiveRecord::Base belongs_to :ministry has_many :officers has_many :projects end File: apps/models/department.rb
    • departments id name ministry_id 1 Jabatan Lanskap dan Taman 1 2 Jabatan Pembangunan Bandar 1 3 Jabatan Imigresen Malaysia 2
    • ministries id name 1 Kementerian Wilayah Persekutuan 2 Kementerian Hal Ehwal Dalam Negeri
    • dept = Department.find(1) => #<Department id: 1, name: 'Jabatan Lanskap dan Taman'> SELECT * FROM departments WHERE id = 1
    • dept.ministry => #<Ministry id: 1, name: 'Kementerian Wilayah Persekutuan'> SELECT * FROM ministries WHERE id = 1
    • class Ministry < ActiveRecord::Base has_many :departments end File: apps/models/ministry.rb
    • ministries id name 1 Kementerian Wilayah Persekutuan 2 Kementerian Hal Ehwal Dalam Negeri
    • departments id name ministry_id 1 Jabatan Lanskap dan Taman 1 2 Jabatan Pembangunan Bandar 1 3 Jabatan Imigresen Malaysia 2
    • ministry = Ministry.find(1) => #<Ministry id: 1, name: 'Kementerian Wilayah Persekutuan'> ministry.departments => [#<Department id: 1, name: 'Jabatan Lanskap dan Taman'>, #<Department id: 2, name: 'Jabatan Pembangunan Bandar'>] SELECT * FROM departments WHERE ministry_id = 1
    • Convention over Configuration
    • ActiveRecord Conventions Model names are singular, e.g. Ministry. Table names are plural, e.g. ministries. Foreign-key columns are named model_id, e.g. ministry_id. Foreign key column goes onto the model that belongs_to another model, e.g. departments table has a column named ministry_id.
    • ActionController Model-View-Controller
    • http://mampu.gov.my/departments/show/1
    • http://mampu.gov.my/departments/show/1 http://mampu.gov.my/controller/action/id
    • /departments/show/1 /controller/action/id class DepartmentsController < ApplicationController def show @dept = Department.find(params[:id]) end end File: apps/controllers/departments_controller.rb
    • Remember this? Department.find(1)
    • /departments/show/1 /controller/action/id class DepartmentsController < ApplicationController def show @dept = Department.find(params[:id]) end end File: apps/controllers/departments_controller.rb
    • Convention over Configuration
    • ActionController Conventions First segment of URL is the controller name, e.g. /departments/show/1, the controller is DepartmentsController. Second segment of URL is the controller action, e.g. /departments/show/1, the action is show in DepartmentsController. Third segment of URL is the ID, e.g. /departments/show/1, the value is accessible from params[:id].
    • ActionView Model-View-Controller
    • Remember this? class DepartmentsController < ApplicationController def show @dept = Department.find(params[:id]) end end
    • http://localhost/departments/show/1 Department: Jabatan Lanskap dan Taman Ministry: Kementerian Wilayah Persekutuan Projects: • Next Generation Network • e-Perolehan Integration
    • <html> <body> <h1>Department: <%= @dept.name %></h1> <h2>Ministry: <%= @dept.ministry.name %></h2> <h2>Projects</h2> <ul> <%= render :partial => @dept.projects %> </ul> </body> </html> File: apps/views/departments/show.html.erb
    • <li><%= project.title %></li> File: apps/views/projects/_project.html.erb
    • http://localhost/departments/show/1 Department: Jabatan Lanskap dan Taman Ministry: Kementerian Wilayah Persekutuan Projects: • Next Generation Network • e-Perolehan Integration
    • Convention over Configuration
    • ActionView Conventions Instance variables set in controller action are automatically available in view, e.g. @dept in previous example. Values are displayed in view by enclosing it in <%= %>. Loops can be extracted into partials. Use Helpers as much as possible to code even less, e.g. link_to, form_for
    • Resources
    • Malaysia.rb Malaysia Ruby Brigade
    • ~65 people in Google Groups ~28 people in Facebook Group
    • Meets every third Thursday of the month
    • Malaysia.rb 3rd Meetup July 2007
    • http://groups.google.com/group/malaysia-rb
    • Local Companies on Rails
    • RSB Freelance Developers
    • Local Ruby on Rails Sites
    • http://www.mampu.gov.my http://www.ravejoint.com http://www.geotude.com http://www.haze.net.my
    • Sneak Preview of Time Together
    • Your Department’s Next Internal Web Application