Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't figure out associations in Rails_Admin

I have two models like so:

class Kid < ActiveRecord::Base
  belongs_to :sex
  attr_accessible :name
end

class Sex < ActiveRecord::Base
  attr_accessible :description
  has_many :kids
end

But for the life of me, I cannot figure out how to get the association to show up in the admin. When I go to edit a kid, I see a label for sex, but there is no dropdown, no hint whatsoever that RailsAdmin sees the association. It just shows the label name, a blank space and the word "optional" below.

I've searched through the dox over and over and over, yet I can't find a solution. I'm a noob, so it's possible I looked right over it and should be subject to ridicule.

I have not modified any other admin code.

like image 719
Ryan McNeill Avatar asked Feb 20 '23 20:02

Ryan McNeill


1 Answers

The relation should be accessible in Kid, try to add sex_id to accessible attributes.

class Kid < ActiveRecord::Base
  belongs_to :sex
  attr_accessible :name, :sex_id
end

like image 86
Gaël Marziou Avatar answered Mar 02 '23 18:03

Gaël Marziou