sorting belongs to association field

43 views
Skip to first unread message

John Gesimondo

unread,
Oct 19, 2012, 1:44:58 AM10/19/12
to rails...@googlegroups.com
Hey everyone. I'm trying to do something seemingly simple and can't figure it out. 

An article belongs to a state. When editing the article, I want the states list to be in alphabetical order (by :name). But they are appearing by :id desc.

I have tried 
  • setting a default_scope on the state model to order(:name)
  • overriding the column in rails admin config (see below)
  config.model Article do
    list do; end
    export do; end
    show do; end
    edit do
      field :title
      field :state do
        sortable :name
      end
      field :school
      ...
    end
    create do; end
    update do; end
  end

No matter what I do, the states always appear id desc.

Any suggestions?

John
Reply all
Reply to author
Forward
Message has been deleted
0 new messages