Skip to content

Instantly share code, notes, and snippets.

@torrick
Created May 23, 2011 13:55

Revisions

  1. torrick created this gist May 23, 2011.
    38 changes: 38 additions & 0 deletions companies.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    ActiveAdmin.register Company do
    filter :name
    filter :customer_type, :as => :check_boxes

    index do
    column :name, :sortable => :name do |company|
    auto_link(company)
    end
    column :active do |company|
    company.active? ? icon(:check) : icon(:x)
    end
    end

    show :title => :name do
    panel "Company Details" do
    attributes_table_for company do
    row :name
    row :notes
    row(:active) { company.active? ? icon(:check) : icon(:x) }
    end
    end

    if company.app_servers.count > 0
    panel "App Servers" do
    table_for(company.app_servers) do |t|
    t.column(:name) { |server| link_to server.name, admin_company_app_server_path(company, server) }
    t.column("Internal IP", :internal_ip)
    t.column("External IP", :external_ip)
    t.column() { |server| link_to "Edit", edit_admin_company_app_server_path(company, server) }
    end
    end
    else
    panel "App Servers" do
    link_to 'New App Server', new_admin_company_app_server_path(company)
    end
    end
    end
    end