SlideShare a Scribd company logo
merb.intro     :by  =>    "Paul Barry" "Paul Barry"
What is Merb? A Ruby MVC Web Framework similar to Rails, but: •  Small •  Fast •  Light •  Less Opinionated
Create Your App $ merb-gen app blog ~/projects
Configure Your App config/init.rb use_orm  :activerecord dependency  "merb-action-args" dependency  "merb-assets" dependency  "merb-builder" dependency  "merb-parts" dependency  "merb_activerecord" dependency  "merb_helpers"
Configure Your Database config/database.yml development: adapter: sqlite3 database: dev.db timeout: 5000 test: adapter: sqlite3 database: test.db timeout: 5000
Generate a Model $ merb-gen model article title:string body:text ~/projects/blog
Create the Table $ rake db:migrate ~/projects/blog
Create an Article $ merb -i >> article = Article.new(:title => 'First Post')‏ => #<Article id: nil...> >> article.body = 'Lorem ipsum dolor sit amet...' => &quot;Lorem ipsum dolor sit amet...&quot; >> article.save!=> true ~/projects/blog
Create a Controller app/controllers/articles.rb class   Articles  < Application def   index &quot;Hello, World!&quot; end end
Create RESTful Route config/router.rb Merb :: Router .prepare  do  | r | r.resources  :articles end
Start Merb $ merb ~/projects/blog
View the controller
Named Route config/router.rb r.match( &quot;/sleep/:time&quot; ).to( :controller  =>  &quot;sleeper&quot; ,  :action  =>  &quot;execute&quot; ).name( :sleeper )‏
Blocking Controller app/controllers/sleeper.rb class   Sleeper  < Application def   execute (time = 5 )‏ sleep time.to_i &quot;I slept for  #{time}  seconds&quot; end end
Non-Blocking Controller app/controllers/sleeper.rb class   Sleeper  < Application def   execute (time = 5 )‏ render_deferred  do sleep time.to_i &quot;I slept for  #{time}  seconds&quot; end end end
Demo
Create a Real Action app/controllers/articles.rb class   Articles  < Application def   index @articles   =   Article .find( :all ,  :limit  =>  5 ,  :order  =>  &quot;created_at desc&quot; )‏ display  @articles end end
Create the View app/views/articles/index.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <% throw_content  :page_title ,  &quot;Articles&quot;  %> <% throw_content  :sidebar   do  %> <%= partial  'shared/me'  %> <%  end  %> <%= partial  'article' ,  :with  =>  @articles  %>
Create the Partial app/views/articles/_article.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <div id= &quot;article_ <%= article.id %> &quot;  class= &quot;article&quot; > <h2> <%= link_to h(article.title), url( :article , article) %> </h2> <p class= &quot;posted_at&quot; > Posted at <%= article.created_at.strftime  &quot;%l:%M %p&quot;  %>  on  <%= article.created_at.strftime  &quot;%A, %B %e&quot;  %> <p> <%= h(article.body) %> </p> </div>
Create the Shared Partial app/views/shared/_me.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <h2> About Me </h2> <%= image_tag  &quot;me.jpg&quot;  %>
Create the Layout app/views/layout/articles.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <html> <head> <title> Merb Blog - <%= catch_content  :page_title  %> </title> <%= css_include_tag  'application'  %> <%= catch_content  :html_head  %> </head> <body> <div id= &quot;page&quot; > <div id= &quot;header&quot; ><h1> Merb Blog </h1></div> <div id= &quot;content&quot; > <%= catch_content %> </div> <div id= &quot;sidebar&quot; > <%= catch_content  :sidebar  %> </div> </div> </body> </html>
View Articles
Create the Show Action app/controllers/articles.rb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> def   show (id)‏ @article   =   Article .find_by_id(id)‏ raise   NotFound   unless   @article display  @article end
Create the Show View app/views/show.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <% throw_content  :page_title , h( @article .title) %> <% throw_content  :sidebar   do  %> <%= partial  'shared/me'  %> <%  end  %> <%= partial  'article' ,  :with  =>  @article  %>
View Article <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %>
Add RSS Mime Type config/init.rb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> Merb .add_mime_type  :rss ,  nil ,  %w[text/xml]
Add RSS to Provides app/controllers/articles.rb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> class   Articles  < Application provides  :rss def   index @articles   =   Article .find( :all ,  :limit  =>  5 ,  :order  =>  &quot;created_at desc&quot; )‏ display  @articles end   end
Create RSS Builder app/views/articles/index.rss.builder <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> xml.instruct!  :xml ,  :version  =>  &quot;1.0&quot;   xml.rss  :version  =>  &quot;2.0&quot;   do xml.channel  do xml.title  &quot;Merb Blog&quot; xml.description  &quot;The greatest blog in the world&quot; xml.link  &quot; http://merb.blog &quot; @articles .each  do  | a | xml.item  do xml.title a.title xml.description a.body xml.pubDate a.created_at.to_s( :rfc822 )‏ xml.link url( :article , a)‏ xml.guid url( :article , a)‏ end end end end
Add Auto-Discovery Link app/views/articles/index.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <% throw_content  :html_head   do  %> <link rel= &quot;alternate&quot;  type= &quot;application/rss+xml&quot;   title= &quot;RSS&quot;  href= &quot;/articles.rss&quot;  /> <%  end  %>
RSS Icon <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %>
RSS Feed <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %>
Create Recent Article Part <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],app/parts/recent_articles.rb
Recent Article Part View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/parts/views/recent_articles/index.html.erb <h2> Recent Articles </h2> <ul> <%  @articles .each  do  | a | %> <li> <%= link_to h(a.title), url( :article , a) %> </li> <%  end  %> </ul>
Add Part to View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/articles/show.html.erb <% throw_content  :sidebar   do  %> <%= partial  'shared/me'  %> <%= part  RecentArticles  =>  &quot;index&quot; ,  :limit  =>  5  %> <%  end  %>
Recent Articles <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %>
Generate Admin Controller <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> ~/projects/blog $ merb-gen resource_controller admin/articles  create  app/controllers/admin  create  app/helpers/admin  create  app/views/admin/articles  create  app/controllers/admin/articles.rb  create  app/helpers/admin/articles_helper.rb  create  app/views/admin/articles/edit.html.erb  create  app/views/admin/articles/index.html.erb  create  app/views/admin/articles/new.html.erb  create  app/views/admin/articles/show.html.erb
Add Admin Route <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> config/router.rb Merb :: Router .prepare  do  | r | r.namespace  :admin   do  | admin | admin.resources  :articles end   r.resources  :articles end
View Routes <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> ~/projects/blog $ merb -i >> merb.show_routes Named Routes edit_admin_article: /admin/articles/:id/edit delete_admin_article: /admin/articles/:id/delete article: /articles/:id admin_articles: /admin/articles new_article: /articles/new admin_article: /admin/articles/:id edit_article: /articles/:id/edit articles: /articles new_admin_article: /admin/articles/new delete_article: /articles/:id/delete
Admin Articles View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/admin/articles/index.html.erb <h2> Articles </h2> <p> <%= link_to  &quot;Create New Article&quot; , url( :new_admin_article ) %> <ul> <%  @articles .each  do  | a | %> <li> <%= link_to h(a.title), url( :admin_article , a) %> </li> <%  end  %> </ul>
Admin New Article View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/admin/articles/new.html.erb <h2> New Article </h2> <%= partial  'form'  %>
Admin Edit Article View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/admin/articles/edit.html.erb <h2> Edit Article </h2> <%= partial  'form'  %>
Admin Article Form <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/admin/articles/_form.html.erb <%= error_messages_for  :article  %> <% form_for  @article ,  :action  => url( :admin_article ,  @article )  do  %> <div class= &quot;field&quot; > <%= text_control  :title ,  :label  =>  'Title'  %> </div> <div class= &quot;field&quot; > <%= text_area_control  :body ,  :rows  =>  20 ,  :cols  =>  80  %> <div> <div class= &quot;buttons&quot; > <%= submit_button  'Save'  %> </div> <%  end  %>
Create a New Article <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %>
Admin Article View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/admin/articles/show.html.erb <h2> <%=h  @article .title %> </h2> <p> <%=h  @article .body %> </p> <hr /> <%= link_to  &quot;Back to Articles&quot; , url( :admin_articles ) %> | <%= link_to  &quot;Edit this Article&quot; , url( :edit_admin_article ,  @article ) %>
So is it worth it?
Numbers <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> min  avg  max  stddev rails GET /articles  37.4  45.7  47.0  2.0  rails GET /articles/1  44.0  45.1  45.8  0.6  merb GET /articles  70.0  71.1  73.0  0.8  merb GET /articles/1  88.0  107.1  110.1  7.2 requests/second
Thank You! http://merbivore.com #merb on irc.freenode.net http://mwrc2008.conf reaks.com/02zygmuntowicz.html http://paulbarry.co m Resources

More Related Content

What's hot

My Story With Flickr
My Story With FlickrMy Story With Flickr
My Story With Flickr
Jose Martinez
 
Query Classification on Steroids with BERT
Query Classification on Steroids with BERTQuery Classification on Steroids with BERT
Query Classification on Steroids with BERT
Hamlet Batista
 
Fast Loading JavaScript
Fast Loading JavaScriptFast Loading JavaScript
Fast Loading JavaScript
Aaron Peters
 
Web APIs & Google APIs
Web APIs & Google APIsWeb APIs & Google APIs
Web APIs & Google APIs
Pamela Fox
 
Rendering SEO Manifesto - Why we need to go beyond JavaScript SEO
Rendering SEO Manifesto - Why we need to go beyond JavaScript SEORendering SEO Manifesto - Why we need to go beyond JavaScript SEO
Rendering SEO Manifesto - Why we need to go beyond JavaScript SEO
Onely
 
Debugging rendering problems at scale
Debugging rendering problems at scaleDebugging rendering problems at scale
Debugging rendering problems at scale
Giacomo Zecchini
 
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
Lincoln III
 
Solving Complex JavaScript Issues and Leveraging Semantic HTML5
Solving Complex JavaScript Issues and Leveraging Semantic HTML5Solving Complex JavaScript Issues and Leveraging Semantic HTML5
Solving Complex JavaScript Issues and Leveraging Semantic HTML5
Hamlet Batista
 
Recipe book flipped-coding
Recipe book flipped-codingRecipe book flipped-coding
Recipe book flipped-coding
Milecia McGregor
 
Mashups & APIs
Mashups & APIsMashups & APIs
Mashups & APIs
Pamela Fox
 
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry WhiteGTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
Gerry White
 
Make your PWA feel more like an app
Make your PWA feel more like an appMake your PWA feel more like an app
Make your PWA feel more like an app
Önder Ceylan
 
Getting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial GadgetsGetting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial GadgetsAtlassian
 
seo savage 2012
seo savage 2012seo savage 2012
seo savage 2012
darkthrone287
 
Schema.org and the changing world of Rich Results - SEOEdinburgh Meetup
Schema.org and the changing world of Rich Results - SEOEdinburgh MeetupSchema.org and the changing world of Rich Results - SEOEdinburgh Meetup
Schema.org and the changing world of Rich Results - SEOEdinburgh Meetup
Geoff Kennedy
 
Double Loop: TDD & BDD Done Right!
Double Loop: TDD & BDD Done Right!Double Loop: TDD & BDD Done Right!
Double Loop: TDD & BDD Done Right!
Jessica Mauerhan
 
Migrating a large scale banking app to compose
Migrating a large scale banking app to composeMigrating a large scale banking app to compose
Migrating a large scale banking app to compose
Fatih Giris
 
Make Your Own Damn SEO Tools (Using Google Docs!)
Make Your Own Damn SEO Tools (Using Google Docs!)Make Your Own Damn SEO Tools (Using Google Docs!)
Make Your Own Damn SEO Tools (Using Google Docs!)
Sean Malseed
 
Google Wave 20/20: Product, Protocol, Platform
Google Wave 20/20: Product, Protocol, PlatformGoogle Wave 20/20: Product, Protocol, Platform
Google Wave 20/20: Product, Protocol, Platform
Pamela Fox
 

What's hot (19)

My Story With Flickr
My Story With FlickrMy Story With Flickr
My Story With Flickr
 
Query Classification on Steroids with BERT
Query Classification on Steroids with BERTQuery Classification on Steroids with BERT
Query Classification on Steroids with BERT
 
Fast Loading JavaScript
Fast Loading JavaScriptFast Loading JavaScript
Fast Loading JavaScript
 
Web APIs & Google APIs
Web APIs & Google APIsWeb APIs & Google APIs
Web APIs & Google APIs
 
Rendering SEO Manifesto - Why we need to go beyond JavaScript SEO
Rendering SEO Manifesto - Why we need to go beyond JavaScript SEORendering SEO Manifesto - Why we need to go beyond JavaScript SEO
Rendering SEO Manifesto - Why we need to go beyond JavaScript SEO
 
Debugging rendering problems at scale
Debugging rendering problems at scaleDebugging rendering problems at scale
Debugging rendering problems at scale
 
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
 
Solving Complex JavaScript Issues and Leveraging Semantic HTML5
Solving Complex JavaScript Issues and Leveraging Semantic HTML5Solving Complex JavaScript Issues and Leveraging Semantic HTML5
Solving Complex JavaScript Issues and Leveraging Semantic HTML5
 
Recipe book flipped-coding
Recipe book flipped-codingRecipe book flipped-coding
Recipe book flipped-coding
 
Mashups & APIs
Mashups & APIsMashups & APIs
Mashups & APIs
 
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry WhiteGTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
GTM Clowns, fun and hacks - Search Elite - May 2017 Gerry White
 
Make your PWA feel more like an app
Make your PWA feel more like an appMake your PWA feel more like an app
Make your PWA feel more like an app
 
Getting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial GadgetsGetting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial Gadgets
 
seo savage 2012
seo savage 2012seo savage 2012
seo savage 2012
 
Schema.org and the changing world of Rich Results - SEOEdinburgh Meetup
Schema.org and the changing world of Rich Results - SEOEdinburgh MeetupSchema.org and the changing world of Rich Results - SEOEdinburgh Meetup
Schema.org and the changing world of Rich Results - SEOEdinburgh Meetup
 
Double Loop: TDD & BDD Done Right!
Double Loop: TDD & BDD Done Right!Double Loop: TDD & BDD Done Right!
Double Loop: TDD & BDD Done Right!
 
Migrating a large scale banking app to compose
Migrating a large scale banking app to composeMigrating a large scale banking app to compose
Migrating a large scale banking app to compose
 
Make Your Own Damn SEO Tools (Using Google Docs!)
Make Your Own Damn SEO Tools (Using Google Docs!)Make Your Own Damn SEO Tools (Using Google Docs!)
Make Your Own Damn SEO Tools (Using Google Docs!)
 
Google Wave 20/20: Product, Protocol, Platform
Google Wave 20/20: Product, Protocol, PlatformGoogle Wave 20/20: Product, Protocol, Platform
Google Wave 20/20: Product, Protocol, Platform
 

Viewers also liked

Grant Concept Brij Slides
Grant Concept Brij SlidesGrant Concept Brij Slides
Grant Concept Brij Slidesbrijsingh
 
Publicity Art
Publicity ArtPublicity Art
Publicity Art
David Page
 
Weblogs Wikis E Portfolios
Weblogs Wikis E PortfoliosWeblogs Wikis E Portfolios
Weblogs Wikis E PortfoliosBruce Perry
 
Sub Prime Crisis Explained
Sub Prime Crisis ExplainedSub Prime Crisis Explained
Sub Prime Crisis Explained
David Page
 
Weblogs - Wikis - ePortfolios
Weblogs - Wikis - ePortfoliosWeblogs - Wikis - ePortfolios
Weblogs - Wikis - ePortfoliosBruce Perry
 
Creation Story Rewritten
Creation Story RewrittenCreation Story Rewritten
Creation Story Rewritten
David Page
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
David Page
 
Para Mis Friendss
Para Mis FriendssPara Mis Friendss
Para Mis Friendssguestcb5109
 
States Of Matter[1]
States Of Matter[1]States Of Matter[1]
States Of Matter[1]wolffer87
 
The Application Development Lifecycle
The Application Development LifecycleThe Application Development Lifecycle
The Application Development Lifecycle
David Page
 
Brij Singhs Ideas
Brij Singhs IdeasBrij Singhs Ideas
Brij Singhs Ideasbrijsingh
 
I sette peccati capitali dell'albergatore (in tema di reputation) #tourismreload
I sette peccati capitali dell'albergatore (in tema di reputation) #tourismreloadI sette peccati capitali dell'albergatore (in tema di reputation) #tourismreload
I sette peccati capitali dell'albergatore (in tema di reputation) #tourismreload
Mirko Lalli
 
The Yubikey
The YubikeyThe Yubikey
The Yubikey
David Page
 
Travel Appeal Destination
Travel Appeal DestinationTravel Appeal Destination
Travel Appeal Destination
Mirko Lalli
 
Introducción tecnología educativa
Introducción tecnología educativaIntroducción tecnología educativa
Introducción tecnología educativa
Carmen Leonor
 
viamedia portfolio presentation pdf
viamedia portfolio presentation pdfviamedia portfolio presentation pdf
viamedia portfolio presentation pdfRam Ravi
 
States Of Matter Power Point
States Of Matter Power PointStates Of Matter Power Point
States Of Matter Power Pointwolffer87
 
Retooling you CMS- Charting a Successful Course
Retooling you CMS- Charting a Successful CourseRetooling you CMS- Charting a Successful Course
Retooling you CMS- Charting a Successful Course
coastalcandy
 

Viewers also liked (19)

Grant Concept Brij Slides
Grant Concept Brij SlidesGrant Concept Brij Slides
Grant Concept Brij Slides
 
Publicity Art
Publicity ArtPublicity Art
Publicity Art
 
Weblogs Wikis E Portfolios
Weblogs Wikis E PortfoliosWeblogs Wikis E Portfolios
Weblogs Wikis E Portfolios
 
Sub Prime Crisis Explained
Sub Prime Crisis ExplainedSub Prime Crisis Explained
Sub Prime Crisis Explained
 
Weblogs - Wikis - ePortfolios
Weblogs - Wikis - ePortfoliosWeblogs - Wikis - ePortfolios
Weblogs - Wikis - ePortfolios
 
Creation Story Rewritten
Creation Story RewrittenCreation Story Rewritten
Creation Story Rewritten
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Para Mis Friendss
Para Mis FriendssPara Mis Friendss
Para Mis Friendss
 
States Of Matter[1]
States Of Matter[1]States Of Matter[1]
States Of Matter[1]
 
The Application Development Lifecycle
The Application Development LifecycleThe Application Development Lifecycle
The Application Development Lifecycle
 
Cosas
CosasCosas
Cosas
 
Brij Singhs Ideas
Brij Singhs IdeasBrij Singhs Ideas
Brij Singhs Ideas
 
I sette peccati capitali dell'albergatore (in tema di reputation) #tourismreload
I sette peccati capitali dell'albergatore (in tema di reputation) #tourismreloadI sette peccati capitali dell'albergatore (in tema di reputation) #tourismreload
I sette peccati capitali dell'albergatore (in tema di reputation) #tourismreload
 
The Yubikey
The YubikeyThe Yubikey
The Yubikey
 
Travel Appeal Destination
Travel Appeal DestinationTravel Appeal Destination
Travel Appeal Destination
 
Introducción tecnología educativa
Introducción tecnología educativaIntroducción tecnología educativa
Introducción tecnología educativa
 
viamedia portfolio presentation pdf
viamedia portfolio presentation pdfviamedia portfolio presentation pdf
viamedia portfolio presentation pdf
 
States Of Matter Power Point
States Of Matter Power PointStates Of Matter Power Point
States Of Matter Power Point
 
Retooling you CMS- Charting a Successful Course
Retooling you CMS- Charting a Successful CourseRetooling you CMS- Charting a Successful Course
Retooling you CMS- Charting a Successful Course
 

Similar to merb.intro

What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
brynary
 
Haml & Sass presentation
Haml & Sass presentationHaml & Sass presentation
Haml & Sass presentation
bryanbibat
 
Master pages ppt
Master pages pptMaster pages ppt
Master pages pptIblesoft
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On RailsWen-Tien Chang
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
John Brunswick
 
JSP Custom Tags
JSP Custom TagsJSP Custom Tags
JSP Custom Tags
BG Java EE Course
 
EPiServer Web Parts
EPiServer Web PartsEPiServer Web Parts
EPiServer Web Parts
EPiServer Meetup Oslo
 
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7
phuphax
 
User Experience is dead. Long live the user experience!
User Experience is dead. Long live the user experience!User Experience is dead. Long live the user experience!
User Experience is dead. Long live the user experience!
Greg Bell
 
HTML5 Overview
HTML5 OverviewHTML5 Overview
HTML5 Overview
reybango
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
Ignacio Coloma
 
Rich faces
Rich facesRich faces
Rich faces
BG Java EE Course
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialYi-Ting Cheng
 
Meta tags1
Meta tags1Meta tags1
Meta tags1hapy
 
Lecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITPLecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITPyucefmerhi
 
Lecture 6 - Comm Lab: Web @ ITP
Lecture 6 - Comm Lab: Web @ ITPLecture 6 - Comm Lab: Web @ ITP
Lecture 6 - Comm Lab: Web @ ITPyucefmerhi
 
APEX Themes and Templates
APEX Themes and TemplatesAPEX Themes and Templates
APEX Themes and Templates
InSync Conference
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With Blogging
Takatsugu Shigeta
 

Similar to merb.intro (20)

What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
Haml & Sass presentation
Haml & Sass presentationHaml & Sass presentation
Haml & Sass presentation
 
Master pages ppt
Master pages pptMaster pages ppt
Master pages ppt
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
 
JSP Custom Tags
JSP Custom TagsJSP Custom Tags
JSP Custom Tags
 
EPiServer Web Parts
EPiServer Web PartsEPiServer Web Parts
EPiServer Web Parts
 
Html5
Html5Html5
Html5
 
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7
 
User Experience is dead. Long live the user experience!
User Experience is dead. Long live the user experience!User Experience is dead. Long live the user experience!
User Experience is dead. Long live the user experience!
 
HTML5 Overview
HTML5 OverviewHTML5 Overview
HTML5 Overview
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
 
Rich faces
Rich facesRich faces
Rich faces
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 
Meta tags1
Meta tags1Meta tags1
Meta tags1
 
Lecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITPLecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITP
 
Ajax
AjaxAjax
Ajax
 
Lecture 6 - Comm Lab: Web @ ITP
Lecture 6 - Comm Lab: Web @ ITPLecture 6 - Comm Lab: Web @ ITP
Lecture 6 - Comm Lab: Web @ ITP
 
APEX Themes and Templates
APEX Themes and TemplatesAPEX Themes and Templates
APEX Themes and Templates
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With Blogging
 

Recently uploaded

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 

Recently uploaded (20)

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 

merb.intro

  • 1. merb.intro :by => &quot;Paul Barry&quot; &quot;Paul Barry&quot;
  • 2. What is Merb? A Ruby MVC Web Framework similar to Rails, but: • Small • Fast • Light • Less Opinionated
  • 3. Create Your App $ merb-gen app blog ~/projects
  • 4. Configure Your App config/init.rb use_orm :activerecord dependency &quot;merb-action-args&quot; dependency &quot;merb-assets&quot; dependency &quot;merb-builder&quot; dependency &quot;merb-parts&quot; dependency &quot;merb_activerecord&quot; dependency &quot;merb_helpers&quot;
  • 5. Configure Your Database config/database.yml development: adapter: sqlite3 database: dev.db timeout: 5000 test: adapter: sqlite3 database: test.db timeout: 5000
  • 6. Generate a Model $ merb-gen model article title:string body:text ~/projects/blog
  • 7. Create the Table $ rake db:migrate ~/projects/blog
  • 8. Create an Article $ merb -i >> article = Article.new(:title => 'First Post')‏ => #<Article id: nil...> >> article.body = 'Lorem ipsum dolor sit amet...' => &quot;Lorem ipsum dolor sit amet...&quot; >> article.save!=> true ~/projects/blog
  • 9. Create a Controller app/controllers/articles.rb class Articles < Application def index &quot;Hello, World!&quot; end end
  • 10. Create RESTful Route config/router.rb Merb :: Router .prepare do | r | r.resources :articles end
  • 11. Start Merb $ merb ~/projects/blog
  • 13. Named Route config/router.rb r.match( &quot;/sleep/:time&quot; ).to( :controller => &quot;sleeper&quot; , :action => &quot;execute&quot; ).name( :sleeper )‏
  • 14. Blocking Controller app/controllers/sleeper.rb class Sleeper < Application def execute (time = 5 )‏ sleep time.to_i &quot;I slept for #{time} seconds&quot; end end
  • 15. Non-Blocking Controller app/controllers/sleeper.rb class Sleeper < Application def execute (time = 5 )‏ render_deferred do sleep time.to_i &quot;I slept for #{time} seconds&quot; end end end
  • 16. Demo
  • 17. Create a Real Action app/controllers/articles.rb class Articles < Application def index @articles = Article .find( :all , :limit => 5 , :order => &quot;created_at desc&quot; )‏ display @articles end end
  • 18. Create the View app/views/articles/index.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <% throw_content :page_title , &quot;Articles&quot; %> <% throw_content :sidebar do %> <%= partial 'shared/me' %> <% end %> <%= partial 'article' , :with => @articles %>
  • 19. Create the Partial app/views/articles/_article.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <div id= &quot;article_ <%= article.id %> &quot; class= &quot;article&quot; > <h2> <%= link_to h(article.title), url( :article , article) %> </h2> <p class= &quot;posted_at&quot; > Posted at <%= article.created_at.strftime &quot;%l:%M %p&quot; %> on <%= article.created_at.strftime &quot;%A, %B %e&quot; %> <p> <%= h(article.body) %> </p> </div>
  • 20. Create the Shared Partial app/views/shared/_me.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <h2> About Me </h2> <%= image_tag &quot;me.jpg&quot; %>
  • 21. Create the Layout app/views/layout/articles.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <html> <head> <title> Merb Blog - <%= catch_content :page_title %> </title> <%= css_include_tag 'application' %> <%= catch_content :html_head %> </head> <body> <div id= &quot;page&quot; > <div id= &quot;header&quot; ><h1> Merb Blog </h1></div> <div id= &quot;content&quot; > <%= catch_content %> </div> <div id= &quot;sidebar&quot; > <%= catch_content :sidebar %> </div> </div> </body> </html>
  • 23. Create the Show Action app/controllers/articles.rb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> def show (id)‏ @article = Article .find_by_id(id)‏ raise NotFound unless @article display @article end
  • 24. Create the Show View app/views/show.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <% throw_content :page_title , h( @article .title) %> <% throw_content :sidebar do %> <%= partial 'shared/me' %> <% end %> <%= partial 'article' , :with => @article %>
  • 25. View Article <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %>
  • 26. Add RSS Mime Type config/init.rb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> Merb .add_mime_type :rss , nil , %w[text/xml]
  • 27. Add RSS to Provides app/controllers/articles.rb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> class Articles < Application provides :rss def index @articles = Article .find( :all , :limit => 5 , :order => &quot;created_at desc&quot; )‏ display @articles end end
  • 28. Create RSS Builder app/views/articles/index.rss.builder <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> xml.instruct! :xml , :version => &quot;1.0&quot; xml.rss :version => &quot;2.0&quot; do xml.channel do xml.title &quot;Merb Blog&quot; xml.description &quot;The greatest blog in the world&quot; xml.link &quot; http://merb.blog &quot; @articles .each do | a | xml.item do xml.title a.title xml.description a.body xml.pubDate a.created_at.to_s( :rfc822 )‏ xml.link url( :article , a)‏ xml.guid url( :article , a)‏ end end end end
  • 29. Add Auto-Discovery Link app/views/articles/index.html.erb <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> <% throw_content :html_head do %> <link rel= &quot;alternate&quot; type= &quot;application/rss+xml&quot; title= &quot;RSS&quot; href= &quot;/articles.rss&quot; /> <% end %>
  • 30. RSS Icon <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %>
  • 31. RSS Feed <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %>
  • 32.
  • 33. Recent Article Part View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/parts/views/recent_articles/index.html.erb <h2> Recent Articles </h2> <ul> <% @articles .each do | a | %> <li> <%= link_to h(a.title), url( :article , a) %> </li> <% end %> </ul>
  • 34. Add Part to View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/articles/show.html.erb <% throw_content :sidebar do %> <%= partial 'shared/me' %> <%= part RecentArticles => &quot;index&quot; , :limit => 5 %> <% end %>
  • 35. Recent Articles <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %>
  • 36. Generate Admin Controller <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> ~/projects/blog $ merb-gen resource_controller admin/articles create app/controllers/admin create app/helpers/admin create app/views/admin/articles create app/controllers/admin/articles.rb create app/helpers/admin/articles_helper.rb create app/views/admin/articles/edit.html.erb create app/views/admin/articles/index.html.erb create app/views/admin/articles/new.html.erb create app/views/admin/articles/show.html.erb
  • 37. Add Admin Route <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> config/router.rb Merb :: Router .prepare do | r | r.namespace :admin do | admin | admin.resources :articles end r.resources :articles end
  • 38. View Routes <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> ~/projects/blog $ merb -i >> merb.show_routes Named Routes edit_admin_article: /admin/articles/:id/edit delete_admin_article: /admin/articles/:id/delete article: /articles/:id admin_articles: /admin/articles new_article: /articles/new admin_article: /admin/articles/:id edit_article: /articles/:id/edit articles: /articles new_admin_article: /admin/articles/new delete_article: /articles/:id/delete
  • 39. Admin Articles View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/admin/articles/index.html.erb <h2> Articles </h2> <p> <%= link_to &quot;Create New Article&quot; , url( :new_admin_article ) %> <ul> <% @articles .each do | a | %> <li> <%= link_to h(a.title), url( :admin_article , a) %> </li> <% end %> </ul>
  • 40. Admin New Article View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/admin/articles/new.html.erb <h2> New Article </h2> <%= partial 'form' %>
  • 41. Admin Edit Article View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/admin/articles/edit.html.erb <h2> Edit Article </h2> <%= partial 'form' %>
  • 42. Admin Article Form <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/admin/articles/_form.html.erb <%= error_messages_for :article %> <% form_for @article , :action => url( :admin_article , @article ) do %> <div class= &quot;field&quot; > <%= text_control :title , :label => 'Title' %> </div> <div class= &quot;field&quot; > <%= text_area_control :body , :rows => 20 , :cols => 80 %> <div> <div class= &quot;buttons&quot; > <%= submit_button 'Save' %> </div> <% end %>
  • 43. Create a New Article <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %>
  • 44. Admin Article View <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> app/views/admin/articles/show.html.erb <h2> <%=h @article .title %> </h2> <p> <%=h @article .body %> </p> <hr /> <%= link_to &quot;Back to Articles&quot; , url( :admin_articles ) %> | <%= link_to &quot;Edit this Article&quot; , url( :edit_admin_article , @article ) %>
  • 45. So is it worth it?
  • 46. Numbers <% throw_content :page_title, &quot;Articles&quot; %><%= partial 'article', :with => @articles %> min avg max stddev rails GET /articles 37.4 45.7 47.0 2.0 rails GET /articles/1 44.0 45.1 45.8 0.6 merb GET /articles 70.0 71.1 73.0 0.8 merb GET /articles/1 88.0 107.1 110.1 7.2 requests/second
  • 47. Thank You! http://merbivore.com #merb on irc.freenode.net http://mwrc2008.conf reaks.com/02zygmuntowicz.html http://paulbarry.co m Resources