Created
November 10, 2010 08:43
-
-
Save tillsc/670562 to your computer and use it in GitHub Desktop.
Add this to your ApplicationController to get a linking data style url handling (force usage of 'format' in URLs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_filter :ensure_extension | |
# Force an extension to every url. (LD) | |
def ensure_extension | |
redirect_to url_for(:format => (request.format && request.format.symbol) || :html) unless params[:format] | |
end | |
# Set a default value for the :format parameter in url_for and *_url/*_path methods. | |
def default_url_options(options = nil) | |
{:format => params[:format]}.merge(options || {}) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment