SlideShare ist ein Scribd-Unternehmen logo
1 von 95
Downloaden Sie, um offline zu lesen
Ruby on Rails
    BY thegiive




                  ( License by CC   2.0 )
About me

•       ID : thegiive
• SocialPicks.com
•       Ruby on Rails
• Blog : http://lightyror.thegiive.net/
• Email : thegiive at gmail . com
Outline

•             Ruby on Rails
• Ruby on Rails
• Rails
• Active Record
•
• Active Record
Ruby on Rails

                    A
95.00

71.25

47.50
                                                             C
                                        B
23.75

   0
        6   7   8       9     10   11       12   1   2   3       4
A


95.00

71.25

47.50

23.75

   0
        6   7   8   9   10   11   12   1   2   3   4
Before Rails day

                  10%
•   PHP
•
•                       90%
After Rails day
                                  Survey    Bloging


•        2
              PHP               10%
    Project
                          20%              40%
•
•                               30%
Phone time project

•       “
            “


•       20      code
•   3
B


95.00

71.25

47.50

23.75

   0
        6   7   8   9   10   11   12   1   2   3   4
•
•
    •
    •
    •
Coding        RD




Rails




PHP



        0   25   50            75        100
C


95.00

71.25

47.50

23.75

   0
        6   7   8   9   10   11   12   1   2   3   4
PS2   10
After PS2 Day
                          Blog          Survey
              PS2




•                   20%
•                                 30%
    Project
•
              30%                 10%
                            10%
Ruby on Rails

• MVC
• Ruby
• DHH       Basecamp
 Project
• David Heinemeier Hansson
•           DHH
•        26




                             DHH Blog
How Hot is Rails

• Rails 2006     400
          150     24
• 2005 Ruby on Rails
  1500% 2006                700%
• Ruby                 26          13
Rails Clone
•
JAVA (Spring/Hibernate)        Rails
               4           (20       /       )4   (5       /)
                            3293                   1164

                            1161                   113

Class/method               62/549                 55/126


        Justin Gehtland              Blog
• RD
•
•
•        Web Site
• Performance
(


•
•
•   PS2
• Justin Gehtland JAVA : Rails = 3.5 : 1
•           Java : Rails = 25 : 1
• Proc.net PHP : Rails = 10 : 1
• JavaEye            JAVA : Rails = 10 : 1
•                  PHP : Rails = 8 : 1

       http://lightyror.blogspot.com/2006/10/rails.html
Rails
• ORM
• Convention over Configuration
• Don’t Repeat Yourself
• Domain Specific Language
ORM


• Object Relational Mapping
•
• Propel Hibernate Active Record ...
Convention over Configuration

                   <?xml version="1.0" encoding="UTF-8"?>
                   <!DOCTYPE hibernate-mapping

•
                   PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
                   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.d
                   <hibernate-mapping>
                   <class name="test.hibernate.Order" table="orders">
                   <id name="id" type="string" unsaved-value="null" >
                   <column name="id" sql-type="integer" not-null="true"/>
                   <generator class="native"/>

•                  </id>
                   <key column="order_id" />
                   <one-to-many class="test.hibernate.OrderItem" />
                   </set>
                   </class>
                   </hibernate-mapping>
DRY


• Don’t Repeat Yourself
• View         Helper Partial    DRY
• Controller        Module Lib         DRY
Domain Specific Language

• Ruby               DSL
• Rails DB-Driven Web App DSL
 • has_one , has_many , HABTM
 •           symbol ( :abc )
Migration

create_table :stores do |t|
  t.column :name , :string
  t.column :info , :text
  t.column :open_time , :string
  t.column :user_id , :integer
  t.column :created_at , :datetime
  t.column :updated_at , :datetime
 end
Active Record

• Rails
•                 ORM
• Convention over Configuration
•          1:1 1:m n:m
•       MySQL SQL Server Oracle
  SQLite
ORM Example
                     a = People.new
     People
   id        int    a = People.find(1)
 name     varchar
 phone    varchar   a.name = ‘David’
address     text        a.destroy
  sex      enum
                         a.save
Relation Table Example
                               Article
     People
   id        int        id               int
 name     varchar   person_id            int
 phone    varchar      title        varchar
address     text
                     content             text
  sex      enum
                    created_at datatime
Relation ORM
a = People.find(1)

a.articles


a.articles.find(:first)


a.articles << Article.new(...)
Person a
•
•
• Legacy
• Template
“          	
      	
  	
           	
 
                    ”           JAVA
    	
 
                  Python Perl
Rails


•                  .....   ....
    • DHH                  Ruby
    • Ruby   DSL
    •
    •
“                      20%
                          JAVA
     300%
                         ”

    From Beyond Java
Ruby          ?

•
    Ruby Programmming
• Ruby is not Rails
• Rails       Ruby 60%
City                        Neighbor
 id           int                city_id           int
                            neighbor_id            int
name      varchar


                                  “        “   ”
                    “   ”    “
• city            n:m   neighbor
     join table
•
•
function     (A       B        {

 if( B      A            ){

 
 return ‘    ’
	 }else{

 
 for ( A                            C   {

 
 
 if( B       C                {

 
 
 
 return ‘      ’
			}
		}

 
 return ‘    ’
                           Pseudo Code
	}
}
def check ( city_a , city_b )
	 if ( city_a.neighbors.include?(city_b)

 
 return ‘       ’
	 else
	 	 city_a.neighbors.each do | neighbor_of_a |
	 	 	 if (neighbor_of_a.neighbors.include?(city_b) )

 
 
 
 return ‘         ’
	 	 	 end
	 	 end

 
 return ‘       ’
                                    Rails Code
	 end
end
•   Ubi
•    Topic
•
RoR * 1hr


RoR in pratice * 3hr
•
•    10
•
•   Demo Code
•
•
• Inspire by
Code Stats

• Code 270
• 230
•          40
• 80%
•
• Tag
• Urmap
• Search
•
Outline
•
•
•
•
• Urmap API
• Tag
Live Demo RoR


•
•
• Contagions
Demo
• Live Demo With Subversion
•       reversion
• May the force be with me
Stores
 Users                       id     int
id   int                  user_id int


              Comments
              id    int
           user_id  int
           store_id int
code



• svn Committed revision 9.
•
• Yullio Mollio plugin for Rails
•            layout
• script/generate layout_yullio stores sidebar
•            Rails
code


• svn Committed revision 10.
•      sidebar         : 11
•      Store Layout : 12
•              Plugin
• session
• before_filter
•
•
code


• User   : 13
•        : 14
• Rmagick
•
•
file_column


• Base on Rmagick
•          Rails
• Upload
code



•   : 15
• Search Engine + Web API
• Solr + act_as_solr
• Ferret + ast_as_ferret
SQL Search


• Like ‘%....%’
•                 SQL code
• Rails SQL
code


• Committed revision 16.
•       partial template
Urmap API

•
•
• UrMap API
•
    • “ Hello       25   121
                “
    •           GPS
•
...
Cron Script


•      ActiveRecord
• Ruby HTTP POST
code



• Commit reversion 17
Table Relationship


• Active Record
•           console   relationship
code


• Commit reversion 18
• ruby script/console
Comment


•
•
code



• Commit reversion 19
Tag


• ast_as_taggable
• model.tag_with('red library book')
• model.tags
code


• Committed revision 20.
•              Committed revision 21
•
•
•
?
?
Q A

Weitere ähnliche Inhalte

Ähnlich wie Ruby on Rails in UbiSunrise

Practical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyPractical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in Groovy
Guillaume Laforge
 
AP4R on Developers Summit 2008
AP4R on Developers Summit 2008AP4R on Developers Summit 2008
AP4R on Developers Summit 2008
Kato Kiwamu
 
Scaling Twitter 12758
Scaling Twitter 12758Scaling Twitter 12758
Scaling Twitter 12758
davidblum
 

Ähnlich wie Ruby on Rails in UbiSunrise (20)

When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programing
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
 
Practical Groovy DSL
Practical Groovy DSLPractical Groovy DSL
Practical Groovy DSL
 
Merb
MerbMerb
Merb
 
Practical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in GroovyPractical Domain-Specific Languages in Groovy
Practical Domain-Specific Languages in Groovy
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
InterCon - Ruby e Rails
InterCon - Ruby e RailsInterCon - Ruby e Rails
InterCon - Ruby e Rails
 
Front end performance tip
Front end performance tipFront end performance tip
Front end performance tip
 
AP4R on Developers Summit 2008
AP4R on Developers Summit 2008AP4R on Developers Summit 2008
AP4R on Developers Summit 2008
 
Making and Breaking Web Services with Ruby
Making and Breaking Web Services with RubyMaking and Breaking Web Services with Ruby
Making and Breaking Web Services with Ruby
 
Rails For Legacy Apps
Rails For Legacy AppsRails For Legacy Apps
Rails For Legacy Apps
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
Rack
RackRack
Rack
 
.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011
 
09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails
 
Framework Presentation
Framework PresentationFramework Presentation
Framework Presentation
 
Scaling Twitter 12758
Scaling Twitter 12758Scaling Twitter 12758
Scaling Twitter 12758
 
Rails in the Cloud
Rails in the CloudRails in the Cloud
Rails in the Cloud
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Ruby on Rails in UbiSunrise