Created
September 9, 2009 04:29
-
-
Save alexreisner/183467 to your computer and use it in GitHub Desktop.
Rails: use friendly (non-numeric) 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
## | |
# Use the +handle+ instead of the +id+ for URLs. | |
# | |
def to_param | |
handle | |
end |
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
# GET /articles/1 | |
def show | |
@article = Article.find_by_handle!(params[:id]) | |
... | |
end | |
# GET /articles/1/edit | |
def edit | |
@article = Article.find_by_handle!(params[:id]) | |
end | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment