SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
The Rails side!
  Edwin Vlieg - BlueTools




    Twente.rb - november 2008
MoneyBird
    • Simpele facturatie voor kleine bedrijven
    • Facturen aanmaken, versturen en beheren
    • Simpel contactbeheer
    • Binnenkort periodieke facturen
    • Innovatieve Ajax interface voor factuur
            bewerken


Edwin Vlieg — MoneyBird 2008       2
MoneyBird
    • April 2008: eerste idee
    • Juni 2008: prototypes van applicatie gereed
            (HTML mockups met JavaScript
            functionaliteit)
    • September 2008: test versie gereed
    • Oktober 2008: live!

Edwin Vlieg — MoneyBird 2008       3
The Rails side!
+‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐+‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+‐‐‐‐‐+‐‐‐‐‐‐‐+
| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
+‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐+‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+‐‐‐‐‐+‐‐‐‐‐‐‐+
| Controllers          |   977 |   779 |      10 |      89 |   8 |     6 |
| Helpers              |   300 |   194 |       0 |      30 |   0 |     4 |
| Models               |  1340 |   983 |      22 |     127 |   5 |     5 |
| Libraries            |   830 |   575 |       4 |      61 |  15 |     7 |
| Model specs          |  1045 |   826 |       0 |       3 |   0 |   273 |
| View specs           |   252 |   189 |       0 |       0 |   0 |     0 |
| Controller specs     |   678 |   560 |       1 |       6 |   6 |    91 |
| Helper specs         |   185 |   162 |       0 |       0 |   0 |     0 |
| Library specs        |    68 |    57 |       1 |       0 |   0 |     0 |
+‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐+‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+‐‐‐‐‐+‐‐‐‐‐‐‐+
| Total                |  5675 |  4325 |      38 |     316 |   8 |    11 |
+‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐+‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+‐‐‐‐‐‐‐‐‐+‐‐‐‐‐+‐‐‐‐‐‐‐+
  Code LOC: 2531     Test LOC: 1794     Code to Test Ratio: 1:0.7



      Edwin Vlieg — MoneyBird 2008          4
The Rails side!
    • Rails 2.2 (since this week!)
    • PostgreSQL
    • Capistrano

    • Developed in TextMate

Edwin Vlieg — MoneyBird 2008          5
Plugins
    • acts_as_state_machine
    • attachment_fu
    • i18n_labels
    • localized_dates
    • subdomain_fu
    • restful-authentication
Edwin Vlieg — MoneyBird 2008      6
Rails 2.2: I18n
     • Scoping
# Override translate method to consider translate_scope.
def t(text, options = {})
  scope = (translate_scope.dup << options.delete(:subscope)).compact
  super(text, {:scope => scope}.merge(options))
end

# The current translation scope, default to current controller name.
def translate_scope
  @translate_scope || [template.base_path]
end




 Edwin Vlieg — MoneyBird 2008          7
Rails 2.2: I18n
    • Localized labels, based on
            ActiveRecord::human_attribute_name
                       <tr>
                         <th><%= f.label :name %></label></th>
                         <td>
                           <%= f.text_field :name %>
                           <%= error_message_on :contact, :name %>
                         </td>
                       </tr>
                       <tr>
                         <th><%= f.label :contact_name %></th>
                         <td><%= f.text_field :contact_name %></td>
                       </tr>

Edwin Vlieg — MoneyBird 2008              8
Rails 2.2: I18n
    • In locales definition:
                nl:
                  activerecord:
                    attributes:
                      contact:
                        contact_name: Contactpersoon
                        name: Naam of Bedrijfsnaam




Edwin Vlieg — MoneyBird 2008          9
Testing
    •       RSpec

                 •       For testing models (business logic)

                 •       Covers 141 examples

    •       Cucumber

                 •       Plain text stories for integration testing

                 •       Covers 535 steps

    •       Factory girl

    •       Webrat
Edwin Vlieg — MoneyBird 2008              10
Testing: Cucumber
  Feature: invoice
    An user should be able to manage his invoices

      Scenario: Create a new invoice
        Given I'm logged in as edwin at bluetools
        When I follow quot;New invoicequot;
         And I fill in quot;Name or Companynamequot; with quot;Test companyquot;
         And I fill in quot;Addressquot; with quot;Hengelosestraat 534quot;
         And I fill in quot;invoice_zipcodequot; with quot;7500AGquot;
         And I fill in quot;invoice_cityquot; with quot;Enschedequot;
         And I fill in quot;invoice_new_detail_attributes__descriptionquot; with quot;Test descriptionquot;
         And I fill in quot;invoice_new_detail_attributes__pricequot; with quot;123quot;
         And I press quot;Savequot;
        Then an invoice with invoice id quot;2008-0001quot; should exist
         And I should see quot;2008-0001quot;
         And I should see quot;Test companyquot;
         And I should see quot;Test descriptionquot;

      Scenario: Create a new invoice with no invoice details
        Given I'm logged in as edwin at bluetools
        When I follow quot;New invoicequot;
         And I fill in quot;Name or Companynamequot; with quot;Test companyquot;
         And I fill in quot;Addressquot; with quot;Hengelosestraat 534quot;
         And I fill in quot;invoice_zipcodequot; with quot;7500AGquot;
         And I fill in quot;invoice_cityquot; with quot;Enschedequot;
         And I press quot;Savequot;
        Then no invoice with name quot;Test companyquot; should exist
         And I should see quot;Details should contain at least one rowquot;
Edwin Vlieg — MoneyBird 2008                  11
Testing: Cucumber
           • Only ~30 steps defined!
           • Example resource definition and assertion:
Given /^I've created (a|an) ([A-z].*) with ([A-z ].* quot;.*quot;( and )?)+$/ do |_, resource, fields, _| #'
  fields = fields.split(quot; and quot;).collect { |f| r = f.strip.match(/^([A-z ].*) quot;(.*)quot;$/); [r[1].tr(quot; quot;,
quot;_quot;).underscore, r[2]] }.flatten
  Factory(resource.tr(quot; quot;, quot;_quot;).to_sym, Hash[*fields])
end

# Then a company with name quot;foobarquot; should exist
Then /^(a|an|no) ([A-z].*) with ([A-z ].*) quot;(.*)quot; should exist$/ do |condition, resource, field, value|
  if resource.to_class.respond_to?(:exists?)
    condition = condition == 'no' ? false : true
    resource.to_class.exists?({ field.tr(quot; quot;, quot;_quot;).underscore => value }).should == condition
  else
    raise quot;Resource #{resource.classify} isn't a modelquot;
  end
end




       Edwin Vlieg — MoneyBird 2008                12
PDF generation
    • PDF writer:
       • API.... :-(
       • PNG file errors (‘PNG uses more than
                         8 bits’, ‘Invalid filter algorithm 61’)




Edwin Vlieg — MoneyBird 2008              13
PDF generation
    • Prawn
       • API... :-)
       • Better PNG support
       • Only the Euro sign doesn’t show up


Edwin Vlieg — MoneyBird 2008   14
PDF generation
     Prawn::Document.generate(quot;fancy_table.pdfquot;) do

          data = [[quot;Gregory Brownquot;,   quot;gregory.t.brown@fakemail.testquot;   ],
                  [quot;James Healyquot; ,    quot;jimmy@fakemail.testquot;             ],
                  [quot;Ross Perotquot;   ,   quot;ross@fakemail.testquot;              ],
                  [quot;Al Gorequot;      ,   quot;al@fakemail.testquot;                ],
                  [quot;Ralph Naderquot; ,    quot;ralph@fakemail.testquot;             ]]

       table data,
         :position             =>   :center,
         :headers              =>   [quot;Namequot;, quot;Emailquot;],
         :row_colors           =>   [quot;ffffffquot;,quot;ffff00quot;],
         :vertical_padding     =>   5,
         :horizontal_padding   =>   3
     end




Edwin Vlieg — MoneyBird 2008            15
Concerned_with
    • Problem: Invoice model has 450 LOC
    • Other models have on average 200 LOC
    • Make the model less fat with
            concerned_with




Edwin Vlieg — MoneyBird 2008   16
Concerned_with
                # In config/initializers
                class << ActiveRecord::Base
                  def concerned_with(*concerns)
                    concerns.each do |concern|
                      require_dependency quot;#{name.underscore}/#{concern}quot;
                    end
                  end
                end

                # In models/invoice.rb
                class Invoice < ActiveRecord::Base
                  concerned_with :validations, :states, :policies, :scopes
                  ...
                end

                # In models/invoice/validations.rb
                class Invoice
                  validates_presence_of ...
                end



Edwin Vlieg — MoneyBird 2008                17
Invoice edit interface
    • Difference between new and edit action:
    • ‘edit’ is performed on an persistant
            instance
    • ‘new’ does not exist after the request has
            finished




Edwin Vlieg — MoneyBird 2008   18
Invoice edit interface
    • Solution: always load the complete form on
            the background
    • Switch between display and form with JS
    • Just plain old submitting the complete form
            for creating a new record




Edwin Vlieg — MoneyBird 2008   19
Invoice edit interface
    • Input is validated and rendered via an Ajax
            call.

                  <div id=quot;invoice_descriptionquot;>
                    <div class=quot;showquot;>
                      <%= render :partial => quot;invoice_descriptionquot; %>
                    </div>
                    <div class=quot;formquot;>
                      <%= render :partial => quot;invoice_description_formquot; %>
                    </div>
                  </div>




Edwin Vlieg — MoneyBird 2008                20
The End!
Try MoneyBird for free at www.moneybird.nl




          info@moneybird.nl
            blog.bluetools.nl

Contenu connexe

En vedette

深圳市潜在购房者调查(部分)
深圳市潜在购房者调查(部分)深圳市潜在购房者调查(部分)
深圳市潜在购房者调查(部分)
Vincent YU
 

En vedette (16)

Cueva santa
Cueva santa Cueva santa
Cueva santa
 
mPay Gateway Presentation
mPay Gateway PresentationmPay Gateway Presentation
mPay Gateway Presentation
 
海江南推广演示文件
海江南推广演示文件海江南推广演示文件
海江南推广演示文件
 
深圳市潜在购房者调查(部分)
深圳市潜在购房者调查(部分)深圳市潜在购房者调查(部分)
深圳市潜在购房者调查(部分)
 
Cartuja valldecrist
Cartuja valldecristCartuja valldecrist
Cartuja valldecrist
 
Life sabina teix pi negre
Life sabina teix pi negreLife sabina teix pi negre
Life sabina teix pi negre
 
Anona Tv Company Presentation
Anona Tv   Company PresentationAnona Tv   Company Presentation
Anona Tv Company Presentation
 
Wentworth Institute 2010
Wentworth Institute 2010Wentworth Institute 2010
Wentworth Institute 2010
 
Object Oriented Programming for web applications
Object Oriented Programming for web applicationsObject Oriented Programming for web applications
Object Oriented Programming for web applications
 
Guia temps 2011
Guia temps 2011Guia temps 2011
Guia temps 2011
 
Docker at MoneyBird
Docker at MoneyBirdDocker at MoneyBird
Docker at MoneyBird
 
Frontend ontwikkeling
Frontend ontwikkelingFrontend ontwikkeling
Frontend ontwikkeling
 
From Idea to Business
From Idea to BusinessFrom Idea to Business
From Idea to Business
 
Temps guia 2012
Temps guia 2012Temps guia 2012
Temps guia 2012
 
Docker from a team perspective
Docker from a team perspectiveDocker from a team perspective
Docker from a team perspective
 
Advanced Testing on RubyEnRails '09
Advanced Testing on RubyEnRails '09Advanced Testing on RubyEnRails '09
Advanced Testing on RubyEnRails '09
 

Similaire à MoneyBird - The Rails Side

Rails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity PresentationRails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity Presentation
railsconf
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2
Byrne Reese
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
Wen-Tien Chang
 
Supersize me
Supersize meSupersize me
Supersize me
dominion
 

Similaire à MoneyBird - The Rails Side (20)

Rails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity PresentationRails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity Presentation
 
Ajax On S2 Odp
Ajax On S2 OdpAjax On S2 Odp
Ajax On S2 Odp
 
Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2Hacking Movable Type Training - Day 2
Hacking Movable Type Training - Day 2
 
Neil Patel - What You Need to be Measuring and How to Do It
Neil Patel - What You Need to be Measuring and How to Do ItNeil Patel - What You Need to be Measuring and How to Do It
Neil Patel - What You Need to be Measuring and How to Do It
 
How Not To Code Flex Applications
How Not To Code Flex ApplicationsHow Not To Code Flex Applications
How Not To Code Flex Applications
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
Microsoft ASP.NET 4.0 : What's Next?
Microsoft ASP.NET 4.0 : What's Next?Microsoft ASP.NET 4.0 : What's Next?
Microsoft ASP.NET 4.0 : What's Next?
 
Wai Aria - An Intro
Wai Aria - An IntroWai Aria - An Intro
Wai Aria - An Intro
 
Front End on Rails
Front End on RailsFront End on Rails
Front End on Rails
 
Make Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance TestingMake Everyone a Tester: Natural Language Acceptance Testing
Make Everyone a Tester: Natural Language Acceptance Testing
 
Satchmo
SatchmoSatchmo
Satchmo
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Libraries
 
Javascript Basic
Javascript BasicJavascript Basic
Javascript Basic
 
Ten modules I haven't yet talked about
Ten modules I haven't yet talked aboutTen modules I haven't yet talked about
Ten modules I haven't yet talked about
 
Page Caching Resurrected
Page Caching ResurrectedPage Caching Resurrected
Page Caching Resurrected
 
Supersize me
Supersize meSupersize me
Supersize me
 
Opensocial Codelab
Opensocial CodelabOpensocial Codelab
Opensocial Codelab
 
Haml, Sass & Compass
Haml, Sass & CompassHaml, Sass & Compass
Haml, Sass & Compass
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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...
 
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
 
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
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

MoneyBird - The Rails Side