Created
October 31, 2013 17:51
-
-
Save laspluviosillas/7254002 to your computer and use it in GitHub Desktop.
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
class User | |
attr_accessible :full_name | |
belongs_to :company | |
end | |
class Company | |
attr_accessible :name | |
has_many :users | |
has_one :primary_admin, class_name: 'User', conditions: ['users.primary_admin = true'] | |
delegate :full_name , :to => :primary_admin, :allow_nil => true | |
end | |
# admin/user.rb | |
ActiveAdmin.register User, as: "Users" do | |
controller do | |
def scoped_collection | |
resource_class.includes(:company) | |
end | |
end | |
filter :id | |
filter :company_name, as: :string | |
index do | |
column :company | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment