Search code examples
ruby-on-railsransack

How to just use the polyamorous gem from ransack


From looking at the code, the ransack gem has included a gem called polyamorous. I only want to use the polyamorous functionality which extends ActiveRecord's associations to support polymorphic belongs_to associations.

Given ransack takes quite a bit of memory, is there a way of just using the polyamorous gem in ransack? There is a standalone version of polyamorous but it is no longer maintained.


Solution

  • The following worked in my Gemfile:

    git 'git@github.com:activerecord-hackery/ransack.git' do
      gem 'polyamorous'
    end
    

    However, this does not work on Heroku due to incorrect permissions, so I would like to know if it is possible to also do this from rubygems.

    It appears that the ransack team intend to release a standalone gem. In the mean time, you can put in your gem file gem 'ransack', require: false and

    # config/initializers/ransack.rb
    require 'polyamorous'
    

    which means only the polyamorous code will be loaded from ransack.