gregbell/active_admin — pull request #785 by mhuggins (2011-11-25 04:50:57+00:00)
Title: Fix linking to ActiveAdmin actions for models that define to_param

If a model defines `to_param` in order to display pretty SEO-friendly URL's, ActiveAdmin links don't work. For example:

class Post < ActiveRecord::Base
attr_accessible :title, :permalink

before_create :generate_permalink

def to_param
permalink
end

protected

def generate_permalink
permalink ||= title.parameterize
end
end

In ActiveAdmin, all the links are called in a manner such as `admin_post_path(post)`, which will become `/admin/posts/hello-world` for example. When ActiveAdmin attempts to load that page, RecordNotFound is raised since it's performing a find on the `id` column, not the `permalink` column.

The solution is to build all links with the record's `id`, e.g.: `admin_post_path(post.id)`.

This pull request implements the above fix. It also includes an updated test that, if tested on the code prior to this pull request, will demonstrate the error.