Your SlideShare is downloading. ×
Merb
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Merb

1,005
views

Published on

An introduction to Merb

An introduction to Merb

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,005
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Merb An Introduction
  • 2. Who am I?
  • 3. History
  • 4. Key Focus
  • 5. Fast (No code is faster than no code)
  • 6. Memory Efficient
  • 7. Modular (All you need none you don’t)
  • 8. As Simple As Possible
  • 9. Features
  • 10. Plugins as Gems
  • 11. Rack Integration
  • 12. File upload example using rack middleware uploader = Proc.new do |env| request = Merb::Request.new(env) if request.path =~ //images/upload/ params = request.params FileUtils.mv params[:file][:tempfile].path, Merb.root / 'public' / 'uploads' / params[:file][:filename] headers = {quot;Content-Typequot;=>quot;text/htmlquot;, quot;Locationquot; => quot;/imagesquot;} [302, headers, quot;You are being redirectedquot;] else [404, {}, quot;No Upload here, move alongquot;] end end merb = Merb::Rack::Application.new run Rack::Cascade.new([uploader, merb])
  • 13. Router
  • 14. Optional Path Segments Matching match(quot;/articles(/:year(/:month(/:day)))/:titlequot;). to(:controller => quot;articlesquot;, :action => quot;showquot;). name(:article) Generating /articles/Hello => { :title => “Hello” } /articles/2008/07/Hello => { :year => “2008”, :month => “07”, :title => “Hello” }
  • 15. Access to Request & Params match(quot;/secretquot;).defer_to do |request, params| if request.session.authenticated? params end end http://www.slideshare.net/carllerche/merb-pluming-the-router-presentation
  • 16. Controllers
  • 17. class Posts < Application provides :xml def show @post = Post.get(params[:id]) display @post end end
  • 18. Background Processing
  • 19. render_then_call do send_notification end run_later do send_notification end
  • 20. Exceptions
  • 21. class Exceptions < Merb::Controller # handle NotFound exceptions (404) def not_found render :format => :html end # handle NotAcceptable exceptions (406) def not_acceptable render :format => :html end end
  • 22. Merb Slice
  • 23. Application Server
  • 24. merb -e produciton -d -c 4 Processes • master • spawner • worker Hot Deploy kill HUP ‘master process id’
  • 25. Questions?