New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined method 'each_with_index' after upgrading Rails from 4.2.8 to 5.0.3 #83
Comments
Hm. Something is up with Axlsx and Rails. Can you post a bigger stack trace? |
@holgum Did you try Axlsx 2.1.0.pre? There is activity on the issue of the next release of Axlsx (3.00). That should solve many issues. |
Here is stacktrace from console (forgot to mention this is JRuby - same was used w/ Rails 4.2)
|
@straydogstudio - can't use 2.1.0-pre as I need rubyzip > 1.2.1 |
Tried Same error. |
Swapped out jruby-9.1.10.0 for ruby-2.3.4 and it works fine, so must be an issue w/ JRuby. |
I was wondering about that. Thanks for the info. Hopefully you aren't too dependent on jRuby. Row comes from SimpleTypedList, which is an Axlsx class which delegates to array methods. each_with_index should be delegated, since it isn't actually there. Something isn't working right with that and jRuby's array class I expect. Might be worth watching, although it says the issue is resolved for 9.1.10.0: jruby/jruby#4610 |
I don't think I would call this 'closed' just yet. Unfortunately we are stuck with JRuby on this project - which means we are stuck at Rails 4.2 until this is resolved. Or use another solution for exporting to xls. Tried with JRuby 9.1.3.0 which I already had installed. Same problem. |
Actionpack is where the abstract controller is, which is what axlsx_rails interacts with, being a renderer. It is a lighter weight dependency than all of rails. That's a pretty general dependency. I wouldn't expect it to be the issue, but you never know. I've reopened the issue. Have you tried generating the report entirely in the controller, without axlsx_rails as a dependency, just axlsx? I would not expect any difference, but it will make it clear that the problem is axlsx, not axlsx_rails. xlsx_package = Axlsx::Package.new()
#your template code
send_data xlsx_package.to_stream.read, type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filename: "filename.xlsx" |
Or it will make it clear that there is a dependency problem. |
Tried putting code above into controller - same error.
so I guess axlsx_rails is off the hook? |
Looks like it. If I have a chance I'll poke around in it anyway. I suggest you create an issue on the Axlsx gem. I searched and didn't see any related issue. But reference this issue if you do. |
I've confirmed using an isolated environment (a Docker jRuby image) that each_with_index doesn't come along with Array.instance_methods here: https://github.com/randym/axlsx/blob/d136835f3a3a54831ad2c7c793a51d3a57273892/lib/axlsx/util/simple_typed_list.rb#L158 |
I have a hack for a given Rails app. In Array.include Enumerable This seems rather unnecessary. But it does work. |
To show each_with_index is missing in Rails with Docker:
|
And yet running it outside of the Rails console shows each_with_index is there in JRuby 9.1.10.0. I'm good with your workaround for now, though. Thanks. |
I think it will end up in Rails. I'm doing what I can to test MRI with the same setup, and see the difference in |
Confirmed each_with_index is also missing in Rails 5.1, and present with MRI. Rails issue: rails/rails#29329 |
Submitted to JRuby where it is a duplicate of #4723. Should be fixed now. |
I have a simple template that was working fine before upgrading to Rails 5.0.3:
After upgrading to Rails 5.0.3 I get:
The problem (which I can duplicate from the Rails console) is occurring as soon as 'add_row' is called.
My Gemfile (before and after Rails upgrade):
Actual version of asxlx_rails in Gemfile.lock is '0.5.1' in both cases.
Any idea if this is a bug or I am missing something?
The text was updated successfully, but these errors were encountered: