DOC PREVIEW
K-State CIS 764 - Happiness leads to Productivity

This preview shows page 1-2-3-24-25-26 out of 26 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Why rails?Carlos KirkconnellGoogleHappiness leads to ProductivityHappiness Matters“Programmers often feel joy when they can concentrate on the creative side of programming, so Ruby is designed to make programmers happy.”Yukihiro Matsumoto“Ruby makes me happy because it allows me to write beautiful code. Aesthetics are strongly linked to enjoyment. It’s not just about getting the job done”.David Heinemeier Hansson“You can recognize truth by its beauty and simplicity. When you get it right, it is obvious that it is right.”Richard Feynman, ScientistAccount.transaction(carlos, vera) do carlos.withdraw(100) vera.deposit(100)endclass Account < ActiveRecord::Baseendclass Account < ActiveRecord::Base validates_presence_of :subdomain, :name, :email_address, :password validates_uniqueness_of :subdomain validates_acceptance_of :terms_of_service, :on => :create validates_confirmation_of :password, :email_address, :on => :create endclass Project < ActiveRecord::Base belongs_to :portfolio has_one :project_manager has_many :milestones has_and_belongs_to_many :categoriesendclass Project < ActiveRecord::Base belongs_to :portfolio has_one :project_manager, :class_name => 'Person' has_many :milestones, :dependent => true has_and_belongs_to_many :categories, :join_table => 'categorizations'endclass Account < ActiveRecord::Base has_many :people do def find_or_create_by_name(name) first_name, last_name = name.split last_name = last_name.join ' ' find_or_create_by_first_name_and_last_name(first_name, last_name) end endendperson = Account.find(:first).people.find_or_create_by_name("Gordon Freeman")person.first_name # => "Gordon"person.last_name # => "Freeman"class Post < ActiveRecord::Base has_many :commentsendclass Comment < ActiveRecord::Base def self.search(query) find(:all, :conditions => ["body = ?", query]) endend# SELECT * FROM comments WHERE post_id = 1 AND body = 'hi'greetings = Post.find(1).comments.search('hi')Real MVCModelModelControlControllerlerViewView.html.htmlViewView.xml.xmlViewView..atomatomclass PhotographersController < ApplicationController # GET /photographers # GET /photographers.xml def index @photographers = Photographer.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @photographers } end end # GET /photographers/1 # GET /photographers/1.xml def show @photographer = Photographer.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @photographer } end endendcreatcreateereadreadupdatupdateedeletdeleteepostpostgetgetputputdeletdeleteeinsertinsertselectselectupdatupdateedeletdeleteeHTTPActive RecordSQLRESTRESTIt’s all about CRUDclass Plan < ActiveRecord::Base has_and_belongs_to_many :usersendclass User < ActiveRecord::Base has_and_belongs_to_many :plansendclass Plan < ActiveRecord::Base has_many :subscriptions has_many :users, :through => :subscriptionsendclass User < ActiveRecord::Base has_many :subscriptions has_many :plans, :through => :subscriptionsendclass Subscription < ActiveRecord::Base belongs_to :user belongs_to :plan validates_presence_of :subscription_dateendRails is RESTful by default•we get a free HTTP API•support for multiple mime types•simpler controllers•a better designed modelAll controllers have 7 actions•index => GET /photographers•show => GET /photographers/2•new => GET /photographers/new•edit => GET /photographers/2/edit•create => POST /photographers•update => PUT /photographers/2•delete => DELETE /photographers/2page[:graph].src = graph_path(@sync.burndown_id)page.replace_html :notice, flash[:notice]flash.discardpage.visual_effect :shake, :graphRJS and AjaxRails invites you to...•write unit, functional & integration tests•use design patterns (Active Record, MVC, Observers)•work on different environments (development, test, production)•use migrations to manage db changes•validate forms•log errorsAt the cost of...•speed, ruby is interpreted...•no intellisense•no dialogs, wizards, or IDE•learning a lot about html and


View Full Document

K-State CIS 764 - Happiness leads to Productivity

Documents in this Course
Load more
Download Happiness leads to Productivity
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Happiness leads to Productivity and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Happiness leads to Productivity 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?