Polymorphic Associations and Formtastic in ActiveAdmin

I have a simple polymorphic association:

class Highlight < ActiveRecord::Base
  belongs_to :highlightable, polymorphic: true
end

class Property < ActiveRecord::Base
  has_many :highlights, as: :highlightable
end

class Destination < ActiveRecord::Base
  has_many :highlights, as: :highlightable
end

      

In the active_admin form to create a new Highlight item, how can I assign it to either Property or Destination?

+3


source to share


1 answer


You can add this to the selection form:



f.input : highlightable_type, as: :select, collection: {"Property" => "property", "Destination" => "destination"}

      

0


source







All Articles