I've managed to use act_as_list with my Models (it was quite easy) one by one, but now i have a problem.
In my app there are 3 models: Facility, Service and Activity. I need to use acts_as_list on their union... is it possible to do that?
Hope my question is clear
You should use a fourth model with a polymorphic association, then put the list on that.
First, read up on polymorphic associations to understand this: http://guides.rubyonrails.org/association_basics.html#polymorphic-associations
Now you'll want to have a class that looks like this:
class Position < ActiveRecord::Base
  belongs_to :positionable, polymorphic: true
end
And a migration that looks like this:
class CreatePositions < ActiveRecord::Migration
  def change
    create_table :position do |t|
      t.integer :positionable_id
      t.string  :positionable_type
      t.timestamps
    end
  end
end
Then on each of the other models add this:
class Facility < ActiveRecord::Base
  has_one :position, as: :positionable
  # ...
end
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With