Skip to content

Instantly share code, notes, and snippets.

@jodosha
Created May 30, 2009 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jodosha/120532 to your computer and use it in GitHub Desktop.
Save jodosha/120532 to your computer and use it in GitHub Desktop.
map.resources :tags
class Tag < ActiveRecord::Base
has_permalink :name, :unless => lambda { |tag| tag.name.blank? }
def to_param
permalink
end
end
class TagsController < ApplicationController
def show
@tag = Tag.find_by_permalink!(params[:id])
end
end
<!-- generic view -->
<%= link_to h(@tag.name), tag_path(@tag) %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment