简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM