Module: Aenea::ActiveAdmin::ResourceController::FindSluggable

Included in:
Aenea::ActiveAdmin::ResourceController
Defined in:
lib/aenea/active_admin/resource_controller/find_sluggable.rb

Instance Method Summary collapse

Instance Method Details

#find_resourceObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/aenea/active_admin/resource_controller/find_sluggable.rb', line 5

def find_resource
  if resource_class < Sluggable
    if params[:id] =~ /\A\d+\z/
      return scoped_collection.find params[:id]
    else
      return scoped_collection.find_by_url! params[:id]
    end
  end

  return scoped_collection if scoped_collection.class < ActiveRecord::Base # has_one

  scoped_collection.find(params[:id])
end