Question

Okay, using ActiveAdmin (0.6.3) and am able to use the following code to get a caller's location attribute to appear in the table of callers. The name of each location appears as a link to the "show" action for the location. The "show" action and result is not useful for my application. I want to remove the link but keep the text. Help? Thanks :)

ActiveAdmin.register Caller do
  index do
    column 'Location', :location, :sortable => 'locations.name'
  end
  controller do
    def scoped_collection
      resource_class.includes(:location)
    end
  end
end

class Caller < ActiveRecord::Base
  attr_accessible :active, :assignedname, :callingnumber, :description, :location_id, :lookupcount, :lastlookuptime
  belongs_to :location
end

class Location < ActiveRecord::Base
  attr_accessible :active, :description, :name, :callers_attributes
  has_many :callers, dependent: :destroy
end
Était-ce utile?

La solution

Try this.

index do
  column 'Location', :sortable => 'locations.name' do |caller|
    caller.location.name
  end
end
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top