Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Array.instance_methods different for jRuby inside Rails #4733
Submitted this to Rails, they declined the issue as being a jRuby problem. Resubmitted here should you wish to address.
Needed each_with_index in Array.instance_methods. Found it was missing (along with several other methods) within Rails when using jRuby 9.
Steps to reproduce
To check MRI, replace the jruby image with ruby.
Whether in our out of Rails, using MRI or jRuby, Array.instance_methods should return the same thing.
When using jRuby 9 inside Rails 5.0, Array.instance_methods doesn't have each_cons, each_entry, each_with_index, each_with_object, as well as several other methods. They are present with MRI. Outside Rails they are present in jRuby.
This is the difference, which may contain some artifacts due to other required gem changes between MRI and jRuby:
[:all?, :byebug, :chunk, :chunk_while, :collect_concat, :detect, :each_cons, :each_entry, :each_with_index, :each_with_object, :entries, :exclude?, :find, :find_all, :flat_map, :grep, :grep_v, :group_by, :index_by, :inject, :lazy, :many?, :max_by, :member?, :min_by, :minmax, :minmax_by, :none?, :one?, :partition, :pluck, :reduce, :singleton_method, :slice_after, :slice_before, :slice_when, :sort_by, :sum, :to_h, :to_ruby, :to_set]
Rails version: 5.0.3 or 5.1.1
Ruby version: jRuby 184.108.40.206, MRI 2.4.1p111
Found because the Axlsx gem uses Array.instance_methods to delegate methods. When used inside Rails 5.0 with jRuby it fails. See randym/axlsx#533
Submitted and declined as a Rails issue: rails/rails#29329