Web Development with Ruby on Rails, MyGOSSCON 2007

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

1 comments

Comments 1 - 1 of 1 previous next Post a comment

  • + myPajamanation N S 2 years ago
    great intro... thanks

Post a comment
Embed Video
Edit your comment Cancel

1 Favorite

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

  1. Web Development with Ruby on Rails MyGOSSCON 2007 Kamal Fariz Mahyuddin RSB
  2. A full-stack framework for developing database-backed web applications according to the Model-View-Controller pattern.
  3. 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/
  4. 2004 6 7 5
  5. > 1 million downloads
  6. Hundreds of plugins
  7. ~10k people on rubyonrails-talk
  8. DB2 SybaseASA Informix Firebird MySQL SQLite Oracle PostgreSQL SQL Server
  9. Ruby on Rails Model-View-Controller
  10. MVC is like a bakery shop.
  11. ActionController Model-View-Controller
  12. ActiveRecord Model-View-Controller
  13. ActionView Model-View-Controller
  14. ActiveRecord Model-View-Controller
  15. class Department < ActiveRecord::Base belongs_to :ministry has_many :officers has_many :projects end File: apps/models/department.rb
  16. departments id name ministry_id 1 Jabatan Lanskap dan Taman 1 2 Jabatan Pembangunan Bandar 1 3 Jabatan Imigresen Malaysia 2
  17. ministries id name 1 Kementerian Wilayah Persekutuan 2 Kementerian Hal Ehwal Dalam Negeri
  18. dept = Department.find(1) => #<Department id: 1, name: 'Jabatan Lanskap dan Taman'> SELECT * FROM departments WHERE id = 1
  19. dept.ministry => #<Ministry id: 1, name: 'Kementerian Wilayah Persekutuan'> SELECT * FROM ministries WHERE id = 1
  20. class Ministry < ActiveRecord::Base has_many :departments end File: apps/models/ministry.rb
  21. ministries id name 1 Kementerian Wilayah Persekutuan 2 Kementerian Hal Ehwal Dalam Negeri
  22. departments id name ministry_id 1 Jabatan Lanskap dan Taman 1 2 Jabatan Pembangunan Bandar 1 3 Jabatan Imigresen Malaysia 2
  23. 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
  24. Convention over Configuration
  25. 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.
  26. ActionController Model-View-Controller
  27. http://mampu.gov.my/departments/show/1
  28. http://mampu.gov.my/departments/show/1 http://mampu.gov.my/controller/action/id
  29. /departments/show/1 /controller/action/id class DepartmentsController < ApplicationController def show @dept = Department.find(params[:id]) end end File: apps/controllers/departments_controller.rb
  30. Remember this? Department.find(1)
  31. /departments/show/1 /controller/action/id class DepartmentsController < ApplicationController def show @dept = Department.find(params[:id]) end end File: apps/controllers/departments_controller.rb
  32. Convention over Configuration
  33. 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].
  34. ActionView Model-View-Controller
  35. Remember this? class DepartmentsController < ApplicationController def show @dept = Department.find(params[:id]) end end
  36. http://localhost/departments/show/1 Department: Jabatan Lanskap dan Taman Ministry: Kementerian Wilayah Persekutuan Projects: • Next Generation Network • e-Perolehan Integration
  37. <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
  38. <li><%= project.title %></li> File: apps/views/projects/_project.html.erb
  39. http://localhost/departments/show/1 Department: Jabatan Lanskap dan Taman Ministry: Kementerian Wilayah Persekutuan Projects: • Next Generation Network • e-Perolehan Integration
  40. Convention over Configuration
  41. 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
  42. Resources
  43. Malaysia.rb Malaysia Ruby Brigade
  44. ~65 people in Google Groups ~28 people in Facebook Group
  45. Meets every third Thursday of the month
  46. Malaysia.rb 3rd Meetup July 2007
  47. http://groups.google.com/group/malaysia-rb
  48. Local Companies on Rails
  49. RSB Freelance Developers
  50. Local Ruby on Rails Sites
  51. http://www.mampu.gov.my http://www.ravejoint.com http://www.geotude.com http://www.haze.net.my
  52. Sneak Preview of Time Together
  53. Your Department’s Next Internal Web Application

+ kamal.farizkamal.fariz, 2 years ago

custom

3532 views, 1 favs, 3 embeds more stats

I prepared these slides for my talk at the Malaysia more

More Info

© All Rights Reserved

Go to text version
  • Total Views 3532
    • 3476 on SlideShare
    • 56 from embeds
  • Comments 1
  • Favorites 1
  • Downloads 160
Most viewed embeds
  • 53 views on http://blog.bitfluent.com
  • 2 views on http://www.workingwithrails.com
  • 1 views on http://wildfire.gigya.com

more

All embeds
  • 53 views on http://blog.bitfluent.com
  • 2 views on http://www.workingwithrails.com
  • 1 views on http://wildfire.gigya.com

less

Flagged as inappropriate Flag as inappropriate
Flag as innappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel

Categories