Ruby on Rails. Computerlabor



Similar documents
1. Was ist das? II. Wie funktioniert das? III. Wo funktioniert das nicht?

Deep in the CRUD LEVEL 1

Comparing Dynamic and Static Language Approaches to Web Frameworks

How To Create A Model In Ruby (Orm)

Ruby on Rails is a web application framework written in Ruby, a dynamically typed programming language The amazing productivity claims of Rails is

Rails 4 Quickly. Bala Paranj.

Building Dynamic Web 2.0 Websites with Ruby on Rails

RESTful Rails Development. translated by Florian Görsdorf and Ed Ruder

Content Management System (Dokument- og Sagsstyringssystem)

Building and Deploying Web Scale Social Networking Applications Using Ruby on Rails and Oracle. Kuassi Mensah Group Product Manager

Pete Helgren Ruby On Rails on i

This tutorial has been designed for beginners who would like to use the Ruby framework for developing database-backed web applications.

Evaluation. Chapter 1: An Overview Of Ruby Rails. Copy. 6) Static Pages Within a Rails Application

Web Development Frameworks

Guides.rubyonrails.org

Outline. Lecture 18: Ruby on Rails MVC. Introduction to Rails

Lecture 3 ActiveRecord Rails persistence layer

Ruby On Rails. CSCI 5449 Submitted by: Bhaskar Vaish

Simple and powerful site deployment with capistrano

Ruby On Rails A Cheatsheet. Ruby On Rails Commands

A Beginner's Guide to Security with Ruby on Rails in BSD. Corey Benninger

Agile Web Development with Rails 4

Ruby on Rails. Object Oriented Analysis & Design CSCI-5448 University of Colorado, Boulder. -Dheeraj Potlapally

Ruby on Rails in GlassFish Sun Microsystems

HAML und SASS. (und COMPASS) markup haiku vs. syntactically awesome stylesheets. Tobias Adam, Jan Krutisch mindmatters GmbH & Co.

Web Development Frameworks Ruby on Rails VS Google Web Toolkit

Ruby on Rails. für Java Entwickler - Ende der Schmerzen - first, last = :mariano, :kamp = #{first}.#{last}@de.ibm.com

CS169.1x Lecture 5: SaaS Architecture and Introduction to Rails " Fall 2012"

Ruby on Rails. a high-productivity web application framework. blog.curthibbs.us/ Curt Hibbs <curt@hibbs.com>

A Framework for Service-Oriented Extensions to Ruby on Rails

Writing Software not code With. Ben Mabey

Brakeman and Jenkins: The Duo Detects Defects in Ruby on Rails Code

web frameworks design comparison draft - please help me improve it focus on Model-View-Controller frameworks

Comparison of modern web frameworks. Nikita Klyukin

Ruby & Ruby on Rails for arkitekter. Kim Harding Christensen khc@kimharding.com

Rails Cookbook. Rob Orsini. O'REILLY 8 Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo

BDD with Cucumber and RSpec. Marcus Ahnve Valtech

Ruby in the context of scientific computing

Ruby on Rails Web Mashup Projects

Why Ruby On Rails? Aaron Bartell Copyright 2014 PowerRuby, Inc.

The IBM i on Rails + + Anthony Avison anthony@powerruby.com. Copyright 2014 PowerRuby, Inc.

Agile Web Development with Rails, Chapter 11: Task F: Add a Dash of Ajax

JRuby Now and Future Charles Oliver Nutter JRuby Guy Sun Microsystems

Android ist anders - Android Dependency Management

Deploying and Monitoring Ruby on Rails A practical guide

Rapid Application Development. and Application Generation Tools. Walter Knesel

Ruby on Rails An Agile Developer s Framework

David and Ruby: a twenty-first century love story

See the installation page

Deploying Physical Solutions to InfoSphere Master Data Management Server Advanced Edition v11

Integrate Rails into an Existing IIS Web infrastructure using Mongrel

VOIP and Ruby. The Convergence of Web and Voice Applications using Open Source Software. Justin Grammens Localtone Interactive

compiled by John McCreesh

Agile Development with Groovy and Grails. Christopher M. Judd. President/Consultant Judd Solutions, LLC

RoR to RubyMotion Writing Your First ios App With RubyMotion. Michael Denomy BostonMotion User Group June 25, 2013

WELCOME TO CITUS CLOUD LOAD TEST

The Other mod_rails: Easy Rails Deployment with JRuby. Nick Sieger Sun Microsystems, Inc

Backend as a Service

Web Framework Performance Examples from Django and Rails

Ruby On Rails. James Reynolds

Creating a generic user-password application profile

Adobe Connect Quick Guide

Customize Bluefin Payment Processing app to meet the needs of your business. Click here for detailed documentation on customizing your application

BEST WEB PROGRAMMING LANGUAGES TO LEARN ON YOUR OWN TIME

Practical Android Projects Lucas Jordan Pieter Greyling

enterprise IBM Rational Team Concert 2 Essentials

VENDORS Welcome to College of DuPage. Next slide please

An Introduction to the Development of Web Applications using Ruby on Rails with Ajax

Electronic Payment Instructions and Tutorial TABLE OF CONTENTS. Getting Started 2. Making a One Time Payment 3. Creating an Account 4

Ricardo Perdigao, Solutions Architect Edsel Garcia, Principal Software Engineer Jean Munro, Senior Systems Engineer Dan Mitchell, Principal Systems

Fact Extraction for Ruby on Rails Platform

Infopark CMS Fiona. Rails Connector for CMS Fiona

MAGENTO Migration Tools

Dasharatham Bitla (Dash)

Java Server Pages combined with servlets in action. Generals. Java Servlets

AJAX SSL- Wizard Reference

Nick Ashley TOOLS. The following table lists some additional and possibly more unusual tools used in this paper.

Makumba and Ruby on Rails

Transcription:

Ruby on Rails Computerlabor

Ablauf Einführung in Ruby Einführung in Ruby on Rails ActiveRecord ActionPack ActiveResource Praxis

Ruby Stichworte 1995 erschienen, Open Source Entwickelt von Yukihoro Matsumoto Vollständig Objektorientiert Interpretiert Dynamische Typbindung (Duck Typing) Garbage Collection

Ruby Implementationen MRI (Matz Ruby Interpret, C) YARV (C) JRuby (Java) Rubinius (Ruby) HotRuby (JavaScript/ActionScript) IronRuby (.NET Framework)

Ruby Syntax 5.times do puts Computerlabor done Alles ist ein Objekt {} oder do..., () optional Keine Variabeldeklaration

Ruby Syntax 10.upto(100) { i puts i }

Ruby Funktionen def zaehle(to => 100) 1.upto(100) { i puts i }

Ruby Funktionen def summiere(a, b) a+b

Ruby OO class Auto def beschleunigen puts Brumm auto = Auto.new auto.beschleunigen

Ruby OO class MegaAuto < Auto def bremsen puts Quietsch auto = MegaAuto.new auto.beschleunigen auto.bremsen

Ruby OO Einfachvererbung Keine abstrakten Klassen Mixins anstelle von Interfaces Metaprogramming

Ruby Accessoren class Person attr_accessor :name attr_reader :alter

Ruby Modifikatoren @instanzvariable @@klassenvariable KONSTANTE public, protected & private self

Ruby Blocks def twice yield yield twice { puts Hello }

Ruby Blocks def twice yield( Olaf ) yield( Sergei ) twice { name puts Hello + name }

Ruby Iteratoren fris = ['Larry', 'Curly', 'Moe'] fris.each { f print f + "\n" }

Ruby on Rails RoR

Ruby on Rails 2004, David Heinemeier Hansson Extrahiert aus Basecamp 100% Ruby

Ruby on Rails Prinzipien DRY (Don t Repeat Yourself) Convention over Configuration Agile Methodiken (u.a. TDD)

Ruby on Rails Patterns Model View Controller Active Record

Model View Controller Model = Datenstruktur View = Darstellung der Struktur Controller = Programmlogik

Typische Anfrage

Active Record Tabelle ist eine Klasse Spalte ist ein Attribut Objekt ist ein Datensatz

Active Record class Person < ActiveRecord:Base Person.find(1) Person.find_by_name Pascal Person.find_by_name_and_firstname Pascal, Zubiger

Active Record Relationen has_many + belongs_to has_and_belongs_to

Active Record Migrations class NeueTabelle < ActiveRecord::Migration def self.up create_table :users do table table.string :name table.string :login, :null => false table.string :password, :limit => 32, :null => false table.string :email def self.down drop_table :users

Active Record Validations validates_acceptance_of :eula validates_associated :comments validates_presence_of :name validates_confirmation_of :password validates_length_of :login, :minimum => 6 validates_length_of :password, :within => 8..25 validates_numericality_of :year, :integer_only => true validates_confirmation_of :password validates_uniqueness_of :email validates_format_of :email, :with => /\A([^@\s]+)@((?: [-a-z0-9]+\.)+[a-z]{2,})\z/i

Rails routes.rb ActionController::Routing::Routes.draw do map map.connect 'products/:id', :controller => 'catalog', :action => 'view' # purchase_url(:id => product.id) map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' map.connect '', :controller => "welcome" # Install the default route as the lowest priority. map.connect ':controller/:action/:id.:format' map.connect ':controller/:action/:id'

Rails Controller class WorldController < ApplicationController def hello rer :text => 'Hello world'

Rails CRUD Controller class BookController < ApplicationController def list; def show; def new; def create; def edit; def update; def delete;

Rails Controller def list @books = Book.find(:all)

Rails Controller def show @book = Book.find(params[:id])

Rails Controller def new @book = Book.new @subjects = Subject.find(:all)

Rails Controller def create @book = Book.new(params[:book]) if @book.save redirect_to :action => 'list' else @subjects = Subject.find(:all) rer :action => 'new'

Rails Controller def edit @book = Book.find(params[:id]) @subjects = Subject.find(:all)

Rails Controller def update @book = Book.find(params[:id]) if @book.update_attributes(params[:book]) redirect_to :action => 'show', :id => @book else @subjects = Subject.find(:all) rer :action => 'edit'

Rails Controller def delete Book.find(params[:id]).destroy redirect_to :action => 'list'

Rails Views <% if @books.blank? %> <p>there are not any books currently in the system.</p> <% else %> <p>these are the current books in our system</p> <ul id="books"> <% @books.each do c %> <li><%= link_to c.title, {:action => 'show', :id => c.id} -%></li> <% %> </ul> <% %> <p><%= link_to "Add new Book", {:action => 'new' }%></p>

Rails Views <h1>add new book</h1> <% form_for :book, @book, :url => { :action => "create" } do f %> <%= f.label :title %> <%= f.text_field :title %><br/> <%= f.label :price %> <%= f.text_field :price %><br/> <%= f.label :subject %> <%= f.collection_select(:subject_id, @subjects, :id, :name) %><br/> <br/> <%= f.label :description %><br/> <%= f.text_area :description %><br/> <br/> <%= submit_tag "Create" %> <% %> <%= link_to 'Back', {:action => 'list'} %>

Layouts Partials Rails Views

IDE s Textmate, Vim, Emacs ;-) Netbeans Aptana Eclipse + RDT Eclipse + DLTK IntelliJ IDEA 3rd Rails

railscast.com peepcode.com ScreenCasts

Bücher Programming Ruby (PragProg - PickAxe) Agile Web Development with Rails (PP) The Ruby Way (AW) The Rails Way (AW) Advanced Rails Receipes

Ressourcen http://www.slideshare.net/jweiss/anintroduction-to-ruby-on-rails/ http://www.slideshare.net/raindoll/ruby-onrails-einfhrung/ http://www.tutorialspoint.com/ruby-on-rails http://www.codyfauser.com/2005/11/20/railsrjs-templates

END Mehr gefällig?

REST

REST routes.rb map.resources :users, :sessions map.resources :teams do teams teams.resources :players

REST helpers link_to "Destroy", team_path(@team), :confirm => "Are you sure?", :method => :delete

Ruby Java Script (RJS)

RJS View <%= javascript_include_tag :defaults %> <h1 id='header'>rjs Template Test</h1> <ul id='list'> <li>dog</li> <li>cat</li> <li>mouse</li> </ul> <%= link_to_remote("add a fox", :url =>{ :action => :add }) %>

RJS Controller def add

add.rjs.erb page.insert_html :bottom, 'list', content_tag("li", "Fox") page.visual_effect :highlight, 'list', :duration => 3 page.replace_html 'header', 'RJS Template Test Complete!'

Capistrano Deployment gem install -y capistrano capify. cap -T

Capistrano Deployment set :application, "set your application name here" set :repository, "set your repository location here" set :deploy_to, "/var/www/#{application}" set :scm, :subversion role :app, "your app-server here" role :web, "your web-server here" role :db, "your db-server here", :primary => true

Capistrano Deployment # Initialies Setup cap deploy:setup # Abhängigkeiten prüfen cap -q deploy:check # Erster Deploy und Migrationen ausführen cap deploy:cold # Weitere Deploys cap deploy # Rollback cap deploy:rollback