• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

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.

Like this presentation? Why not share!

Ruby on Rails at UC Davis

on

  • 854 views

 

Statistics

Views

Total Views
854
Views on SlideShare
854
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

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
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ruby on Rails at UC Davis Ruby on Rails at UC Davis Presentation Transcript

    • Ruby on Rails at UC Davis Charlie Turner IET Mediaworks/CTS University of California, Davis July 30, 2007 cjturner@ucdavis.edu
    • Outline  Background and Motivation  Introduction to Ruby on Rails  Rails applications (demo and ETRA)  Integration with campus services  Maintaining a Rails application  Recommendations  Questions and Discussion
    • The Popularity of RoR  Google ruby-on-rails -> returned 43,100,000 hits  Apple will ship Ruby on Rails with Mac OS X v10.5 "Leopard", scheduled for release in October, 2007.  Active open-source development community  Used in increasing number of production websites  O’Reilly Radar tracking book growth for last two years
    • O’Reilly Categories 06->07
    • Ruby and Rails Timeline 1993 Yukihiro “Matz” Matsumoto began Work on Ruby 1995 Ruby released to public 2004 Ruby on Rails developed by David Heinemeier Hansson and released to public 2007 To be shipped with Apple OS X 10.5
    • What is Ruby?  Object-oriented scripting language − syntax inspired by Perl with Smalltalk-like OO features − shares some features with Python and Lisp  Everything is an object “hello”.length => 5 or 20.to_s => “20”  Define functions/methods def say_hello_to (name) puts “Hello #{name}” end  Arrays and hashes namevec.each {|n| puts “the name is #{n}”
    • What is Rails?  Application framework − based on the Model-View-Controller (MVC) design pattern  Written in Ruby -> Ruby on Rails  Automate common web application operations − CRUD = Create, Read, Update, Delete  Based on an object-relational model (ORM) for database access  Favor convention over configuration − Scaffolding = standardized code layout, model and method names
    • Model-View-Controller (MVC) Architecture routing browser controllers database views models
    • Object Relational Model  Standard ORM Model − Database tables map to ruby classes − Table rows map to class objects − Row columns map to object attributes  Active Record = Rails ORM − Additional methods for search, sort, validation, etc. − Relationships between tables (foreign keys)  Has_one  Belongs_to  Has_and_belongs_to_many
    • Simple Grant DB in Rails  Create Rails application − % rails etras  Configure Database − create database etras_development and grant access permissions − edit config/database.yml, updating username & password for database  Create Model and migration file − % script/generate model grant − edit file db/migrate/001_create_grants.rb adding table rows − % rake migrate  Create most basic controller − % script/generate controller admin − Edit app/controller/admin_controller.rb adding "scaffold :grant"  Start built-in WEBrick web server − % script/server  Point Browser to application root − http://localhost:3000/admin
    • Grants List View
    • Grant Edit View
    • Grant Models (part) Autogenerated by scaffolding class GrantsController < ApplicationController def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :action => :list } def list @grant_pages, @grants = paginate :grants, :per_page => 10 end def show @grant = Grant.find(params[:id]) end end
    • Grant list.rhtml <h1>Listing grants</h1> <table> <tr> <% for column in Grant.content_columns %> <th><%= column.human_name %></th> <% end %> </tr> <% for grant in @grants %> <tr> <% for column in Grant.content_columns %> <td><%=h grant.send(column.name) %></td> <% end %> <td><%= link_to 'Show', :action => 'show', :id => grant %></td> <td><%= link_to 'Edit', :action => 'edit', :id => grant %></td> <td><%= link_to 'Destroy', { :action => 'destroy', :id => grant }, :confirm => 'Are you sure?', :post => true %></td> </tr> <% end %> </table> <%= link_to 'Previous page', { :page => @grant_pages.current.previous } if @grant_pages.current.previous %> <%= link_to 'Next page', { :page => @grant_pages.current.next } if @grant_pages.current.next %> <br /> <%= link_to 'New grant', :action => 'new' %>
    • Pitfalls to basic scaffold
    • After HTML escape added
    • ETRA Database  Educational and Technology Resource Award (ETRA) − Application database used by UC Davis faculty/staff  All users identified (ldap) and authenticated (Kerberos)  Role-based access control − client, staff, producer, billing, developer  Supporting document attachment, comment tracking  Sorting, searching, grouping of applications  Email notification
    • ETRA Application List
    • ETRA Ajax Search
    • ETRA Show Application
    • Integration with campus services  Distributed Authentication (distauth) / CAS  LDAP  Email
    • Distauth/CAS Integration  Integrated with Apache I and II web server  Installed perl module connects to secure server for authentication  Protected on a directory level - not file by file  Sets browser cookie that is read by Ruby
    • Apache config file
    • Distauth/CAS Integration
    • LDAP access
    • email notification (sample)
    • email notification (view)
    • Experiences maintaining the ETRA RoR Application  Stylesheet changes  Adding control menus  Bookmark bug  Database normalization
    • Stylesheet Changes
    • Stylesheet changes
    • Adding ASC/DESC Menu
    • ASC/DESC controller code
    • ASC/DESC View code
    • Bookmark Bug  Client access highly restricted  Staff originally routed to application listing  Original authentication occurred in one place  Rails uses mod_rewrite − model/method/id − E.g. xyz.ucdavis.edu/show/user/12 − New routings visible to browser and can be bookmarked  Insufficient authentication/identification along all routes
    • Bookmark - before_filter
    • Deployment Issues  Rails new enough that some areas still debated  Heavy-weight runtime environment − Ongoing search for faster web server configuration − Multiple web server options: WEBrick, lighttpd, apache − Fastcgi, fcgi, proxying  Requires mod_rewrite − Increased complexity in apache config files − Can interact with apache CAS/distauth modules − Active development with mongrel, capistrano
    • When to use Rails… Complex skins, Payoff Integration with external Services, deviations from Standard CRUD models Extended Maintenance CRUD applications Investment  Python paradox (Paul Graham) − If a company chooses to write its software in a comparatively esoteric language, they'll be able to hire better programmers, because they'll attract only those who cared enough to learn it. And for programmers the paradox is even more pronounced: the language to learn, if you want to get a good job, is a language that people don't learn merely to get a job. (Paul Graham http://www.paulgraham.com/pypar.html)
    • RoR Resources  Ruby On Rails − http://www.rubyonrails.org/ − See blog video (15 minutes)  Ruby Website − http://www.ruby-lang.org/en/  Ruby Forge − http://rubyforge.org/  Ruby Wikipedia page − http://en.wikipedia.org/wiki/Ruby_programming_language  Programming Ruby − http://www.ruby-doc.org/docs/ProgrammingRuby/  Ruby Central − http://www.rubycentral.org/