Last active
May 6, 2016 02:46
-
-
Save HashNotAdam/d42fd137c8c5b1476700e17534d71e9f to your computer and use it in GitHub Desktop.
Example of how to reproduce rails_admin issue #2627
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
# == Schema Information | |
# | |
# Table name: companies | |
# | |
# id :integer not null, primary key | |
# name :string(255) not null | |
# type :string(255) not null | |
# created_at :datetime | |
# updated_at :datetime | |
# | |
class Company < ActiveRecord::Base | |
end | |
# == Schema Information | |
# | |
# Table name: companies | |
# | |
# id :integer not null, primary key | |
# name :string(255) not null | |
# type :string(255) not null | |
# created_at :datetime | |
# updated_at :datetime | |
# | |
class Client < Company | |
before_create :set_generic_type | |
private | |
# Sub-classed models set the type to Admin::[User Type]::Client instead of | |
# simply Client | |
def set_generic_type | |
self.type = 'Client' | |
end | |
end | |
module Admin | |
module SuperUser | |
class Client < Client | |
# By default, where would include "type = 'Admin::SuperUser::Client'" | |
default_scope { rewhere(type: 'Client') } | |
rails_admin do | |
list do | |
field :name, :show_link do | |
searchable :name | |
end | |
end | |
show do | |
field :id | |
field :name, :show_link | |
end | |
edit do | |
field :name | |
end | |
end | |
end | |
end | |
end | |
module Admin | |
module Reseller | |
class Client < Client | |
# By default, where would include "type = 'Admin::Reseller::Client'" | |
default_scope { rewhere(type: 'Client') } | |
rails_admin do | |
list do | |
field :name, :show_link do | |
searchable :name | |
end | |
end | |
show do | |
field :name, :show_link | |
end | |
edit do | |
field :name | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had to explicitly subclass from
::Client
, or Rails admin gave me a "Circular dependency detected while autoloading constant Admin::Reseller::Client".I'll let you know what else I'm able to figure out.