Microsoft's Internet Explorer browser has no built-in vector graphics machinery required for "loss-free" gradient background themes.
Please upgrade to a better browser such as Firefox, Opera, Safari or others with built-in vector graphics machinery and much more. (Learn more or post questions or comments at the Slide Show (S9) project site. Thanks!)
(Adapted S9 Version from Original PDF Slide Deck by Ezra Zygmuntowicz, Engine Yard @ Mountain West RubyConf 2008)
&:foo or returning allowed!No code is faster than no code.
Just throw more servers at the problem!
Throwing more servers at the problem only goes so far …
Of course I’m happy to sell you more servers ;)
Premature Optimization is the root of blah blah blah…
Postmature Optimization is the root of all hosting bills ;)
config/rack.rb:
class ApiHandler
def initialize(app)
@app = app
end
def call(env)
request = Merb::Request.new(env)
if request.path =~ %r{/api/(.*)}
[200,
{"Content-Type" => "text/json"},
Api.get_json($1)]
else
@app.call(env)
end
end
end
use ApiHandler
run Merb::Rack::Application.new
Merb::Router.prepare do |r|
r.resources :posts do |post|
post.resources :comments
end
end
Named Routes:
| Name | Route |
| delete_post_comment | /posts/:post_id/comments/:id/delete |
| post_comments | /posts/:post_id/comments |
| new_post | /posts/new |
| posts | /posts |
| post_comments | /posts/:post_id/comments/:id |
| edit_post | /posts/:id/edit |
| post | /posts/:id |
| new_post_comment | /posts/:post_id/comments/new |
| delete_post | /posts/:id/delete |
| edit_post_comment | /posts/:post_id/comments/:id/edit |
Merb::Router.prepare do |r|
r.match(%r[^/foo/(.+)], :user_agent => /(MSIE|Gecko)/).
to(:controller => 'foo', :title => '[1]',
:action => 'show', :agent => ':user_agent[1]')
r.match('/bar/:baz').defer_to do |request, params|
if bar = Bar.find_by_baz params[:baz]
{:controller => bar.controller,
:action => bar.action,
:bar => bar.to_param}
end
end
end
Merb.add_mime_type(:yaml, :to_yaml, %w[application/x-yaml text/yaml]) Merb.add_mime_type(:html, :to_html, %w[text/html application/xhtml+xml application/html]) Merb.add_mime_type(:xml, :to_xml, %w[application/xml text/xml application/x-xml], :Encoding => 'UTF-8') Merb.add_mime_type(:json, :to_json, %w[application/json text/x-json])
class Posts < Application
provides :json, :yaml, :xml
def show(id)
@post = Post.find id
display @post
end
end