Skip to content

Instantly share code, notes, and snippets.

@laspluviosillas
Created October 31, 2013 17:51
Show Gist options
  • Save laspluviosillas/7254002 to your computer and use it in GitHub Desktop.
Save laspluviosillas/7254002 to your computer and use it in GitHub Desktop.
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