Closed thromera closed 7 years ago
You'll want to use a newer axlsx_rails than that. The current version is 0.5.1, which has had the Mime references changed for Rails 5.1. Do you know how you got 0.1.5?
Hey @straydogstudio thanks for your answer. By the meantime, I've been looking at the code, and this change fixed the issue for me:
# axlsx_rails-0.1.5/lib/axlsx_rails/action_controller.rb
# L23
# from
send_data render_to_string(options), :filename => download_name, :type => Mime::XLSX, :disposition => disposition
# to
send_data render_to_string(options), :filename => download_name, :type => Mime[:xlsx], :disposition => disposition
(This is probably the fix you're talking about, just posting as a reference).
And for this gem version, it's the default that my bundle install
downloaded.
I installed multiple version to try to fix the issue. First, I followed instructions on the homepage:
If rubyzip >= 1.2.1 is needed:
gem 'rubyzip', '>= 1.2.1'
gem 'axlsx', git: 'https://github.com/randym/axlsx.git', ref: '776037c0fc799bb09da8c9ea47980bd3bf296874'
gem 'axlsx_rails'
Then I tried to bump all versions and the rubyzip from 1.2.2
to 1.1.0
(BTW is it still true?)
and now my gemfile looks like this:
gem 'rubyzip', '~> 1.1.0'
gem 'axlsx', '2.1.0.pre'
gem 'axlsx_rails'
What I don't understand is that I did gem uninstall axlsx
and gem uninstall axlsx_rails
before doing bundle install. Do you think that's something related? Should I manually remove the entries of axlsx*
versions in my Gemfile.lock then re run bundle install
?
I'm currently testing to force the latest version in my Gemfile, I will post a new message to let you know about it.
Thanks anyway!
I'd just make your gemfile contain: `gem 'axlsx_rails', '>= 0.5.1'. But yes, that is the change required in the gem. I may change the README if that is happening so people specify the version.
Ok, thanks.
It worked properly using the latest gem version.
Can you confirm me that the rubyzip
version has to be ~> 1.1.0
>
That should be it for 2.1.0.pre. If you need 1.2.1 or greater you'll have to look at the install instructions for the git ref to choose. I've not dug through Axlsx issues for a while, so they may have a better release. They still haven't released 2.1.0.
Changing to use gem 'axlsx_rails', '>= 0.5.1'
worked for me.
My Gemfile:
gem 'axlsx', git: 'https://github.com/randym/axlsx.git', ref: 'c8ac844' # MIT-License
gem 'axlsx_rails', '>= 0.5.1' # MIT-License
...
gem 'rubyzip', '>= 1.2.1' # Ruby license
If you get the error uninitialized constant Mime::XSLX you have used format.xslx instead of format.xlsx, or something similar.
Since rails 5 make use of Mime[:xlsx] For rails 4 Mime::XLSX
Hello,
I'm currently experiencing issues with the gem, I've this error:
uninitialized constant Mime::XLSX
(Please note that there is no typo ;)).
Versions:
What I did so far:
spring stop
config/initializers/mime_types.rb
Let me know if you need any additional informations.
Thanks!