SlideShare a Scribd company logo
1 of 37
Download to read offline
work.rowanhick.com




                           The Pocket Rocket
                              Framework




Wednesday, June 11, 2008
Discussion tonight
                   • Intended for people who don’t know what
                           Merb is
                   • Good grasp of Rails concepts
                   • Not patient enough to google/irc/blog
                           search etc to get started on Merb
                   • Touch on a lot of features
                   • All links/references up on
                           http://work.rowanhick.com tomorrow
Wednesday, June 11, 2008
About me

                   •       Product Development Mgr for a startup in Toronto

                   •       Full time with Rails for 2.5 years

                   •       Previously PHP/MySQL for 4 years

                   •       6 years Prior QA/BA/PM for Enterprise CAD/
                           CAM software dev company




Wednesday, June 11, 2008
Objects of Desire




                   • What are these doing in a presentation
                           about Ruby web frameworks ?


Wednesday, June 11, 2008
Bikes vs Cars
                   •       The Porsche, you just open the door, turn the key,
                           and drive. It has a/c, a stereo, plush upholstery,
                           everything. Accidents can and do happen but few
                           and far between, but pretty user friendly.

                   •       The sports bike, it's raw, unadulterated. You can't
                           hop on it wrapped in cotton wool, way easier to
                           get burned. However it's faster, easier to replace,
                           modify and tune things at a lower cost.



Wednesday, June 11, 2008
Parallels to the world of MVC?


                 Rails is...
                 • Very user friendly & well documented
                 • suitable for 80% most web projects
                 • a turn-key frame work.

Wednesday, June 11, 2008
...and

                 Merb is...
                 • aiming for that other 20%
                 • fast as all hell
                 • going to require a little more skill to get up
                           and running with
                 • “the framework for hackers”
Wednesday, June 11, 2008
Same same but
                                  different
                   • It’s actually quite similar! (workflow, layout)
                   • However ... don’t start emailing merb
                           groups asking for feature XYZ to be
                           implemented “like it is in Rails”
                   • Don’t expect your app to port without
                           code changes to Merb (although you’d be
                           suprised how little needs to change)


Wednesday, June 11, 2008
Who Built it
                   • Ezra Zygmuntowicz
                   • Yehuda Katz
                   • + many others
                   • You could get some glory too ..
                   • http://gweezlebur.com/2008/2/1/so-you-
                           want-to-contribute-to-merb-core-part-1


Wednesday, June 11, 2008
Key Philosophy

                   •       All you need and none you
                           don’t
                   •       No code is faster than no
                           code


Wednesday, June 11, 2008
Anything that slows Merb
                                down is a bug
                               (my personal favourite)




Wednesday, June 11, 2008
Merb-core -more gems

                   • What the ? Isn’t it just Merb ?
                   • merb-core is the basic slimmed down bare
                           minimum code
                   • merb-more contains niceities to help you
                           along your way (action-args, assets, builder,
                           cache, freezer, gen, haml, jquery, mailer,
                           parts, slices)


Wednesday, June 11, 2008
Switzerland

                   • Merb is the Switzerland of Ruby
                           frameworks
                   • Doesn’t care that you might favour
                           Datamapper over ActiveRecord
                   • Lets you choose ORM, Test Framework, JS
                           Framework, Rack Adaptor



Wednesday, June 11, 2008
Getting started
                   • To start off with get both core and more
                   • gem install merb-core merb-more
                   • choose your ORM
                           ‣   gem install merb-activerecord
                           ‣   gem install sequel
                           ‣   gem sources -a http://gems.datamapper.org && sudo gem install
                               addressable english rspec data_objects do_mysql do_postgres do_sqlite3
                               dm-core dm-more




Wednesday, June 11, 2008
merb-gen

               • Your new friend
               • generates code/files for your app
                           rowan$ merb-gen app speeddemon
                            RubiGen::Scripts::Generate
                                create log
                                create app
                                   ...etc


               •      merb-gen app yourapp --flat (or) --very-flat
                      puts your application on a serious diet.


Wednesday, June 11, 2008
Differences
                                                     RAILS                  MERB
                             Routes             config/routes.rb        config/router.rb
                           Initialization     config/environment.rb       config/init.rb
                     Environment specific      config/environments/*   config/environments/*
                              Plugins            vendor/plugins              gems
                           Migrations              db/migrate         schema/migrations
                             Testing                  test              test (or) spec
                              Public                 public                 public
                             Models               app/models             app/models
                           Controllers           app/controllers        app/controllers
                             Helpers              app/helpers            app/helpers
                                Lib                    lib/            (config in init.rb)


Wednesday, June 11, 2008
vendor/plugins gems
                   • Everything is a gem
                   • Freeze your gems with your app
                   • gem install -i somegem ~/yourapp/gems/       --
                           no-ri --no-rdoc
                   • convert rails plugins, start with merb-gen
                           plugin plugin_name
                   • Lots underway http://github.com/search?
                           q=merb
Wednesday, June 11, 2008
edit config/init.rb
               • Choose your ORM
                      use_orm: activerecord
                      use_test: rspec


               • Include dependencies (eg mailer)
                      dependencies quot;merb_helpersquot;, “merb-parts”
                      Merb::BootLoader.after_app_loads do
                        # Add dependencies here that must load after the
                      application loads:
                        dependencies quot;merb-mailerquot;
                        # dependency quot;magic_adminquot; # this gem uses the
                      app's model classes
                      end

Wednesday, June 11, 2008
I want my database.yml
               • Patience. Because you’ve told merb you want
                      active record, just fire merb for the first
                      time:
                      rowan-laptop:speeddemon rowan$ merb
                       ~ Loaded DEVELOPMENT Environment...
                       ~ loading gem 'merb_activerecord' ...
                       ~ loading gem 'activerecord' ...
                       ~ No database.yml file found in /Users/rowan/testing/speeddemon/
                      config.
                       ~ A sample file was created called database.sample.yml for you to copy
                      and edit.



               • Copy, edit and save.
Wednesday, June 11, 2008
merb-gen generators
               • Let’s you know what you can create
                      automagically:
                      rowan-laptop:b2b_merb rowan$ merb-gen generators

                      .....

                      Installed Generators

                        Rubygems: authenticated, controller, database_sessions_migration,
                      migration, model, part_controller, resource, resource_controller



               • see more http://rubigen.rubyforge.org/

Wednesday, June 11, 2008
merb-gen model
                                 mymodel
                   • Synonymous with script/generate mymodel
                   • Extra points:
                   ✓ dependent on ORM - creates migration or
                           not
                   ✓ dependent on test framework - creates
                           spec or unit test


Wednesday, June 11, 2008
Setup your first REST
                            resource

               • merb-gen again
                      $ merb-gen resource Product title:string


               • Sets up controller, views, model, test code
               • Get coding!

Wednesday, June 11, 2008
Controller code
               • Looks reasonably similar:
                      class Products < Application
                        before :check_access_level
                        provides :xml

                           def index
                             @products = Product.find(:all, :order => :sort_order )
                             display @products
                           end

                           def show
                             @product = Product.find_by_product_id(params[:id])
                             raise NotFound unless @product
                             display @product
                           end
                           ...




Wednesday, June 11, 2008
Key Differences
                                RAILS                        MERB
                           products_controller               products

                           redirect_to( hash )           redirect ( string )

                               respond_to        provides / only_provides / display

                            before/after_filter             before/after

                                 except                       exclude

                              render(hash)       render or render(‘hello world’)
                                *optional           *mandatory to get a view
                                 logger                    merb.logger

                                 url_for                        url


Wednesday, June 11, 2008
display
               •      Display handles mime type response
                      provides :xml
                      def index
                        @product = Product.find(params[:id])
                        display @product
                      end


               •      Goto http://127.0.0.1:4000/product/2.xml

               •      Display then looks for index.xml.erb, if not found
                      then calls @product.to_xml



Wednesday, June 11, 2008
Syntactic sugar

               •      Making controller methods look more like methods
                      def my_action(id)
                        product = Product.find(id)
                      end


               •      Automagically assigns id from params[:id]

               •      In merb-more (merb-action-args)




Wednesday, June 11, 2008
Part Controllers

               •      Reusable 'components' for use in your views

               •      Not accessible from outside world, but can see
                      params hash

               •      Their own generator

               •      Again in merb-more (merb-parts)




Wednesday, June 11, 2008
Implementing Parts
               •      In config/init.rb
                      dependency 'merb-parts'


               •      Use merb-gen to set it up for you
                      $ merb-gen part_controller widget
                      ...
                      create app/helpers/widget_part_helper.rb
                      create app/parts/widget_part.rb
                      create app/parts/views/widget_part/index.html.erb


               •      Edit action(s) then call it from a view
                      <%= WidgetPart => :index %>




Wednesday, June 11, 2008
Exceptions
               •      Handled in app/controllers/exceptions.rb
                           def show
                             @product = Product.find_by_product_id(params[:id])
                             raise NotFound unless @product
                             display @product
                           end


               •      exceptions.not_found method

               •      render out in that view what you want to show for
                      that error




Wednesday, June 11, 2008
Router is Powerful
                   • Example from Yehudas slides at RailsConf




Wednesday, June 11, 2008
Pressing the GO button

               •      Simple
                      merb -p 3000 -e development


               •      Fires up a mongrel instance through merb

               •      Hit it just like regular old rails app




Wednesday, June 11, 2008
Hooking up to
                               webserver
               •      Merb implements a Rack adaptor

               •      Allows you to use different types of application
                      server depending on your needs

               •      Example
                      merb -p 3000 -e production -a thin


               •      Mongrel, Thin, Ebb, Eventd Mongrel, Passenger

               •      Connect Apache/Nginx -> Merb (not) Apache ->
                      Mongrel -> Merb

Wednesday, June 11, 2008
Resources
                             http://merbivore.com               Great videos
                           http://wiki.merbivore.com   http://mwrc2008.confreaks.com/


                             http://merbunity.com
                                                       http://www.slideshare.net/search/
                            http://merborials.com/
                                                               slideshow?q=merb


                                                  http://www.slideshare.net/search/
                  http://github.com/search?q=merb
                                                      slideshow?q=datamapper




Wednesday, June 11, 2008
The million dollar
                               question

                            Should I use it ?


Wednesday, June 11, 2008
How long is a piece of
                          string !



Wednesday, June 11, 2008
work.rowanhick.com




                             The End



Wednesday, June 11, 2008
Credits
                   •       GT3 Pic - http://flickr.com/photos/fiskfisk/
                           433629365/

                   •       Sport bike pic http://flickr.com/photos/
                           markhodgins/2447051098

                   •       Yehudas RailsConf’08 slides for router code

                   •       http://www.wikivs.com/wiki/
                           Merb_vs_Ruby_on_Rails for folder comparison

                   •       Ezra and Yehuda for being the driving forces behind
                           the awesomeness that is Merb + Datamapper

Wednesday, June 11, 2008

More Related Content

Similar to Merb The Super Bike Of Frameworks

Practical Intro Merb
Practical Intro MerbPractical Intro Merb
Practical Intro MerbPaul Pajo
 
Practical Intro Merb
Practical Intro MerbPractical Intro Merb
Practical Intro MerbPaul Pajo
 
Merb presentation at ORUG
Merb presentation at ORUGMerb presentation at ORUG
Merb presentation at ORUGMatt Aimonetti
 
Merb For The Enterprise
Merb For The EnterpriseMerb For The Enterprise
Merb For The EnterpriseMatt Aimonetti
 
Rails Internationalization
Rails InternationalizationRails Internationalization
Rails InternationalizationMike Champion
 
What is Ruby on Rails?
What is Ruby on Rails?What is Ruby on Rails?
What is Ruby on Rails?Karmen Blake
 
Web Standards and Accessibility
Web Standards and AccessibilityWeb Standards and Accessibility
Web Standards and AccessibilityNick DeNardis
 
Portlets
PortletsPortlets
Portletsssetem
 
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 Coursepeter_marklund
 
Introducing Merb
Introducing MerbIntroducing Merb
Introducing MerbBalint Erdi
 
Groovy Testing Aug2009
Groovy Testing Aug2009Groovy Testing Aug2009
Groovy Testing Aug2009guest4a266c
 
CouchDB to the Edge ApacheCon EU
CouchDB to the  Edge ApacheCon EUCouchDB to the  Edge ApacheCon EU
CouchDB to the Edge ApacheCon EUChris Anderson
 
Ruby off Rails (english)
Ruby off Rails (english)Ruby off Rails (english)
Ruby off Rails (english)Stoyan Zhekov
 
What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6Gal Marder
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Railsdosire
 
AJUBY Open Source Application Builder
AJUBY Open Source Application BuilderAJUBY Open Source Application Builder
AJUBY Open Source Application Builderajuby
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The JvmQConLondon2008
 

Similar to Merb The Super Bike Of Frameworks (20)

Practical Intro Merb
Practical Intro MerbPractical Intro Merb
Practical Intro Merb
 
Practical Intro Merb
Practical Intro MerbPractical Intro Merb
Practical Intro Merb
 
Merb presentation at ORUG
Merb presentation at ORUGMerb presentation at ORUG
Merb presentation at ORUG
 
Merb For The Enterprise
Merb For The EnterpriseMerb For The Enterprise
Merb For The Enterprise
 
Rails Internationalization
Rails InternationalizationRails Internationalization
Rails Internationalization
 
Intro To Grails
Intro To GrailsIntro To Grails
Intro To Grails
 
What is Ruby on Rails?
What is Ruby on Rails?What is Ruby on Rails?
What is Ruby on Rails?
 
Web Standards and Accessibility
Web Standards and AccessibilityWeb Standards and Accessibility
Web Standards and Accessibility
 
Portlets
PortletsPortlets
Portlets
 
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
 
Introducing Merb
Introducing MerbIntroducing Merb
Introducing Merb
 
Scaling the Rails
Scaling the RailsScaling the Rails
Scaling the Rails
 
Groovy Testing Aug2009
Groovy Testing Aug2009Groovy Testing Aug2009
Groovy Testing Aug2009
 
CouchDB to the Edge ApacheCon EU
CouchDB to the  Edge ApacheCon EUCouchDB to the  Edge ApacheCon EU
CouchDB to the Edge ApacheCon EU
 
Ruby off Rails (english)
Ruby off Rails (english)Ruby off Rails (english)
Ruby off Rails (english)
 
What's new in Java EE 6
What's new in Java EE 6What's new in Java EE 6
What's new in Java EE 6
 
Jvm Language Summit Rose 20081016
Jvm Language Summit Rose 20081016Jvm Language Summit Rose 20081016
Jvm Language Summit Rose 20081016
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
AJUBY Open Source Application Builder
AJUBY Open Source Application BuilderAJUBY Open Source Application Builder
AJUBY Open Source Application Builder
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The Jvm
 

Recently uploaded

Financial-Statement-Analysis-of-Coca-cola-Company.pptx
Financial-Statement-Analysis-of-Coca-cola-Company.pptxFinancial-Statement-Analysis-of-Coca-cola-Company.pptx
Financial-Statement-Analysis-of-Coca-cola-Company.pptxsaniyaimamuddin
 
International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...ssuserf63bd7
 
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckHajeJanKamps
 
Cyber Security Training in Office Environment
Cyber Security Training in Office EnvironmentCyber Security Training in Office Environment
Cyber Security Training in Office Environmentelijahj01012
 
TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024Adnet Communications
 
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!Doge Mining Website
 
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607dollysharma2066
 
Kenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith PereraKenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith Pereraictsugar
 
Darshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfDarshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfShashank Mehta
 
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607dollysharma2066
 
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort ServiceCall US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Servicecallgirls2057
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Anamaria Contreras
 
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCRashishs7044
 
Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737Riya Pathan
 
Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Peter Ward
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdfShaun Heinrichs
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyotictsugar
 
Appkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxAppkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxappkodes
 

Recently uploaded (20)

Financial-Statement-Analysis-of-Coca-cola-Company.pptx
Financial-Statement-Analysis-of-Coca-cola-Company.pptxFinancial-Statement-Analysis-of-Coca-cola-Company.pptx
Financial-Statement-Analysis-of-Coca-cola-Company.pptx
 
International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...
 
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
 
Cyber Security Training in Office Environment
Cyber Security Training in Office EnvironmentCyber Security Training in Office Environment
Cyber Security Training in Office Environment
 
TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024TriStar Gold Corporate Presentation - April 2024
TriStar Gold Corporate Presentation - April 2024
 
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!
Unlocking the Future: Explore Web 3.0 Workshop to Start Earning Today!
 
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
(Best) ENJOY Call Girls in Faridabad Ex | 8377087607
 
Kenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith PereraKenya Coconut Production Presentation by Dr. Lalith Perera
Kenya Coconut Production Presentation by Dr. Lalith Perera
 
Darshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfDarshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdf
 
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607FULL ENJOY Call girls in Paharganj Delhi | 8377087607
FULL ENJOY Call girls in Paharganj Delhi | 8377087607
 
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort ServiceCall US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.
 
Corporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information TechnologyCorporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information Technology
 
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
8447779800, Low rate Call girls in Uttam Nagar Delhi NCR
 
Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737Independent Call Girls Andheri Nightlaila 9967584737
Independent Call Girls Andheri Nightlaila 9967584737
 
Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...Fordham -How effective decision-making is within the IT department - Analysis...
Fordham -How effective decision-making is within the IT department - Analysis...
 
1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf1911 Gold Corporate Presentation Apr 2024.pdf
1911 Gold Corporate Presentation Apr 2024.pdf
 
Japan IT Week 2024 Brochure by 47Billion (English)
Japan IT Week 2024 Brochure by 47Billion (English)Japan IT Week 2024 Brochure by 47Billion (English)
Japan IT Week 2024 Brochure by 47Billion (English)
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyot
 
Appkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptxAppkodes Tinder Clone Script with Customisable Solutions.pptx
Appkodes Tinder Clone Script with Customisable Solutions.pptx
 

Merb The Super Bike Of Frameworks

  • 1. work.rowanhick.com The Pocket Rocket Framework Wednesday, June 11, 2008
  • 2. Discussion tonight • Intended for people who don’t know what Merb is • Good grasp of Rails concepts • Not patient enough to google/irc/blog search etc to get started on Merb • Touch on a lot of features • All links/references up on http://work.rowanhick.com tomorrow Wednesday, June 11, 2008
  • 3. About me • Product Development Mgr for a startup in Toronto • Full time with Rails for 2.5 years • Previously PHP/MySQL for 4 years • 6 years Prior QA/BA/PM for Enterprise CAD/ CAM software dev company Wednesday, June 11, 2008
  • 4. Objects of Desire • What are these doing in a presentation about Ruby web frameworks ? Wednesday, June 11, 2008
  • 5. Bikes vs Cars • The Porsche, you just open the door, turn the key, and drive. It has a/c, a stereo, plush upholstery, everything. Accidents can and do happen but few and far between, but pretty user friendly. • The sports bike, it's raw, unadulterated. You can't hop on it wrapped in cotton wool, way easier to get burned. However it's faster, easier to replace, modify and tune things at a lower cost. Wednesday, June 11, 2008
  • 6. Parallels to the world of MVC? Rails is... • Very user friendly & well documented • suitable for 80% most web projects • a turn-key frame work. Wednesday, June 11, 2008
  • 7. ...and Merb is... • aiming for that other 20% • fast as all hell • going to require a little more skill to get up and running with • “the framework for hackers” Wednesday, June 11, 2008
  • 8. Same same but different • It’s actually quite similar! (workflow, layout) • However ... don’t start emailing merb groups asking for feature XYZ to be implemented “like it is in Rails” • Don’t expect your app to port without code changes to Merb (although you’d be suprised how little needs to change) Wednesday, June 11, 2008
  • 9. Who Built it • Ezra Zygmuntowicz • Yehuda Katz • + many others • You could get some glory too .. • http://gweezlebur.com/2008/2/1/so-you- want-to-contribute-to-merb-core-part-1 Wednesday, June 11, 2008
  • 10. Key Philosophy • All you need and none you don’t • No code is faster than no code Wednesday, June 11, 2008
  • 11. Anything that slows Merb down is a bug (my personal favourite) Wednesday, June 11, 2008
  • 12. Merb-core -more gems • What the ? Isn’t it just Merb ? • merb-core is the basic slimmed down bare minimum code • merb-more contains niceities to help you along your way (action-args, assets, builder, cache, freezer, gen, haml, jquery, mailer, parts, slices) Wednesday, June 11, 2008
  • 13. Switzerland • Merb is the Switzerland of Ruby frameworks • Doesn’t care that you might favour Datamapper over ActiveRecord • Lets you choose ORM, Test Framework, JS Framework, Rack Adaptor Wednesday, June 11, 2008
  • 14. Getting started • To start off with get both core and more • gem install merb-core merb-more • choose your ORM ‣ gem install merb-activerecord ‣ gem install sequel ‣ gem sources -a http://gems.datamapper.org && sudo gem install addressable english rspec data_objects do_mysql do_postgres do_sqlite3 dm-core dm-more Wednesday, June 11, 2008
  • 15. merb-gen • Your new friend • generates code/files for your app rowan$ merb-gen app speeddemon RubiGen::Scripts::Generate create log create app ...etc • merb-gen app yourapp --flat (or) --very-flat puts your application on a serious diet. Wednesday, June 11, 2008
  • 16. Differences RAILS MERB Routes config/routes.rb config/router.rb Initialization config/environment.rb config/init.rb Environment specific config/environments/* config/environments/* Plugins vendor/plugins gems Migrations db/migrate schema/migrations Testing test test (or) spec Public public public Models app/models app/models Controllers app/controllers app/controllers Helpers app/helpers app/helpers Lib lib/ (config in init.rb) Wednesday, June 11, 2008
  • 17. vendor/plugins gems • Everything is a gem • Freeze your gems with your app • gem install -i somegem ~/yourapp/gems/ -- no-ri --no-rdoc • convert rails plugins, start with merb-gen plugin plugin_name • Lots underway http://github.com/search? q=merb Wednesday, June 11, 2008
  • 18. edit config/init.rb • Choose your ORM use_orm: activerecord use_test: rspec • Include dependencies (eg mailer) dependencies quot;merb_helpersquot;, “merb-parts” Merb::BootLoader.after_app_loads do # Add dependencies here that must load after the application loads: dependencies quot;merb-mailerquot; # dependency quot;magic_adminquot; # this gem uses the app's model classes end Wednesday, June 11, 2008
  • 19. I want my database.yml • Patience. Because you’ve told merb you want active record, just fire merb for the first time: rowan-laptop:speeddemon rowan$ merb ~ Loaded DEVELOPMENT Environment... ~ loading gem 'merb_activerecord' ... ~ loading gem 'activerecord' ... ~ No database.yml file found in /Users/rowan/testing/speeddemon/ config. ~ A sample file was created called database.sample.yml for you to copy and edit. • Copy, edit and save. Wednesday, June 11, 2008
  • 20. merb-gen generators • Let’s you know what you can create automagically: rowan-laptop:b2b_merb rowan$ merb-gen generators ..... Installed Generators Rubygems: authenticated, controller, database_sessions_migration, migration, model, part_controller, resource, resource_controller • see more http://rubigen.rubyforge.org/ Wednesday, June 11, 2008
  • 21. merb-gen model mymodel • Synonymous with script/generate mymodel • Extra points: ✓ dependent on ORM - creates migration or not ✓ dependent on test framework - creates spec or unit test Wednesday, June 11, 2008
  • 22. Setup your first REST resource • merb-gen again $ merb-gen resource Product title:string • Sets up controller, views, model, test code • Get coding! Wednesday, June 11, 2008
  • 23. Controller code • Looks reasonably similar: class Products < Application before :check_access_level provides :xml def index @products = Product.find(:all, :order => :sort_order ) display @products end def show @product = Product.find_by_product_id(params[:id]) raise NotFound unless @product display @product end ... Wednesday, June 11, 2008
  • 24. Key Differences RAILS MERB products_controller products redirect_to( hash ) redirect ( string ) respond_to provides / only_provides / display before/after_filter before/after except exclude render(hash) render or render(‘hello world’) *optional *mandatory to get a view logger merb.logger url_for url Wednesday, June 11, 2008
  • 25. display • Display handles mime type response provides :xml def index @product = Product.find(params[:id]) display @product end • Goto http://127.0.0.1:4000/product/2.xml • Display then looks for index.xml.erb, if not found then calls @product.to_xml Wednesday, June 11, 2008
  • 26. Syntactic sugar • Making controller methods look more like methods def my_action(id) product = Product.find(id) end • Automagically assigns id from params[:id] • In merb-more (merb-action-args) Wednesday, June 11, 2008
  • 27. Part Controllers • Reusable 'components' for use in your views • Not accessible from outside world, but can see params hash • Their own generator • Again in merb-more (merb-parts) Wednesday, June 11, 2008
  • 28. Implementing Parts • In config/init.rb dependency 'merb-parts' • Use merb-gen to set it up for you $ merb-gen part_controller widget ... create app/helpers/widget_part_helper.rb create app/parts/widget_part.rb create app/parts/views/widget_part/index.html.erb • Edit action(s) then call it from a view <%= WidgetPart => :index %> Wednesday, June 11, 2008
  • 29. Exceptions • Handled in app/controllers/exceptions.rb def show @product = Product.find_by_product_id(params[:id]) raise NotFound unless @product display @product end • exceptions.not_found method • render out in that view what you want to show for that error Wednesday, June 11, 2008
  • 30. Router is Powerful • Example from Yehudas slides at RailsConf Wednesday, June 11, 2008
  • 31. Pressing the GO button • Simple merb -p 3000 -e development • Fires up a mongrel instance through merb • Hit it just like regular old rails app Wednesday, June 11, 2008
  • 32. Hooking up to webserver • Merb implements a Rack adaptor • Allows you to use different types of application server depending on your needs • Example merb -p 3000 -e production -a thin • Mongrel, Thin, Ebb, Eventd Mongrel, Passenger • Connect Apache/Nginx -> Merb (not) Apache -> Mongrel -> Merb Wednesday, June 11, 2008
  • 33. Resources http://merbivore.com Great videos http://wiki.merbivore.com http://mwrc2008.confreaks.com/ http://merbunity.com http://www.slideshare.net/search/ http://merborials.com/ slideshow?q=merb http://www.slideshare.net/search/ http://github.com/search?q=merb slideshow?q=datamapper Wednesday, June 11, 2008
  • 34. The million dollar question Should I use it ? Wednesday, June 11, 2008
  • 35. How long is a piece of string ! Wednesday, June 11, 2008
  • 36. work.rowanhick.com The End Wednesday, June 11, 2008
  • 37. Credits • GT3 Pic - http://flickr.com/photos/fiskfisk/ 433629365/ • Sport bike pic http://flickr.com/photos/ markhodgins/2447051098 • Yehudas RailsConf’08 slides for router code • http://www.wikivs.com/wiki/ Merb_vs_Ruby_on_Rails for folder comparison • Ezra and Yehuda for being the driving forces behind the awesomeness that is Merb + Datamapper Wednesday, June 11, 2008