Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 and ActiveAdmin. Filter is displaying Objects not the company name

I have a list of customers but on the filter section on the right column, I get a list like this #<Customer0X0B500> in the select menu. How can I display the company_name attribute of Customer instead?

like image 522
leonel Avatar asked Jan 05 '12 16:01

leonel


2 Answers

Figured it out, thanks!

filter :customer, :collection => proc {(Customer.all).map{|c| [c.company_name, c.id]}}

like image 133
leonel Avatar answered Sep 29 '22 22:09

leonel


i'm not sure I understand you but probably you should define to_s method inside your Customer class e.g.

class Customer

  def to_s
    self.company_name
  end

end

it would be easier if you shared some code

like image 42
codevoice Avatar answered Sep 29 '22 23:09

codevoice