This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
jcarroll (author)
Fri Feb 22 12:07:16 -0800 2008
commit d111e93cfb115999985c63f2a5a95299f87542c9
tree c8547b158254d7d192aaa4caa29b9dd0e9f16c9a
parent e269f3d5aa80c7ccf00f06ac6b1119fa64862e56
tree c8547b158254d7d192aaa4caa29b9dd0e9f16c9a
parent e269f3d5aa80c7ccf00f06ac6b1119fa64862e56
what /
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Wed Feb 20 08:46:15 -0800 2008 | |
| |
README | Wed Feb 20 15:11:54 -0800 2008 | |
| |
Rakefile | Mon Feb 18 20:31:47 -0800 2008 | |
| |
init.rb | Fri Feb 22 12:07:16 -0800 2008 | |
| |
install.rb | ||
| |
lib/ | ||
| |
tasks/ | Mon Feb 18 20:31:47 -0800 2008 | |
| |
test/ | ||
| |
uninstall.rb |
What
====
What provides boolean query methods on Mime::Type instances
for the native Rails mime-types. You now have these methods
available from your controllers:
request.format.atom?
request.format.css?
request.format.csv?
request.format.html?
request.format.ics?
request.format.js?
request.format.json?
request.format.multipart_form?
request.format.rss?
request.format.text?
request.format.url_encoded_form?
request.format.xml?
request.format.yaml?
... and any custom mime types that you add in any environment specific config files.
Examples
========
# config/initializers/mime_types.rb
Mime::Type.register 'text/iphone', :iphone
# app/controllers/what_controller.rb
class WhatController < ApplicationController
before_filter :csv?, :iphone?
def index
render :text => 'index'
end
protected
def csv?
if request.format.csv?
redirect_to login_url
end
end
def iphone?
if request.format.iphone?
redirect_to login_url
end
end
end
What is especially powerful in combination with When.
# app/controllers/what_controller.rb
class WhatController < ApplicationController
before_filter :login, :if => :csv?
before_filter :login, :if => lambda { |controller| controller.request.format.iphone? }
def index
render :text => 'index'
end
protected
def csv?
request.format.csv?
end
def login
redirect_to login_url
end
end
Copyright (c) 2008 Dan Croak, Jared Carroll, and thoughtbot, inc. released under the MIT license












