Skip to content
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

Missing template with version 0.5.2 #100

Open
swiehr opened this issue May 15, 2018 · 13 comments
Open

Missing template with version 0.5.2 #100

swiehr opened this issue May 15, 2018 · 13 comments

Comments

@swiehr
Copy link

swiehr commented May 15, 2018

With version 0.5.2 I suddenly get missing template errors with code that works perfectly fine with 0.5.1

Catching the exception I see that the :axslx handler is missing but could not figure out why and how to fix this:

ActionView::MissingTemplate
Missing template my_class/index, application/index with {
  :locale=>[:en], 
  :formats=>[:xlsx], 
  :variants=>[], 
  :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :rsb]
}

My controller code looks like this:

respond_to do |format|
  format.html { render :template => 'my_class/index', :layout => !request.xhr? }
  format.api
  format.xlsx { render :filename => "my_class.xlsx" }
end

I am using the gem in different Redmine configurations:

  • Redmine 3.2.0, Ruby 2.2.5, Rails 4.2.5.1
  • Redmine 3.3.3, Ruby 2.3.1, Rails 4.2.7.1

Common is

  • axlsx (2.1.0.pre a2259b0)
  • axlsx_rails (0.5.2)

any hints welcome...

@straydogstudio
Copy link
Collaborator

@swiehr Thanks. I'll look into it.

@straydogstudio
Copy link
Collaborator

@swiehr Have you had any luck on this? I've tried several ways and have not been able to reproduce it so far, although I have yet to chase it down Redmine context, which I will do next.

I would change your code to something more specific (I don't get the specified filename without specifying the template):
format.xlsx { render xlsx: "templatename.xlsx.axlsx", :filename => "my_class.xlsx" }

@straydogstudio
Copy link
Collaborator

@swiehr How are you integrating axlsx_rails into Redmine?

@swiehr
Copy link
Author

swiehr commented Jun 12, 2018

@straydogstudio Tried your proposal with explicitly giving the template name, unfortunately to no avail.
Regarding integration into Redmine I am not sure what information you need - I am using it in a Redmine plugin which provides own data structures and views, so basically there is nothing Redmine specific.

My Gemfile has this (enabled) group

group :axlsx do
  gem 'acts_as_xlsx', github: 'swiehr/acts_as_xlsx'
  gem 'axlsx', git: 'https://github.com/randym/axlsx.git', ref: 'a2259b0cb1000215491b5301a16f250098961a2c'
  gem 'axlsx_rails', '= 0.5.2'
  gem 'rubyzip', '= 1.2.0'
end

In my plugins init.rb I have

Rails.application.config.after_initialize do
  plugin = Redmine::Plugin.find(:my_plugin)
    begin
      require 'acts_as_xlsx'
      require 'axlsx_rails'
      MY_FEATURE[:gem_axlsx] = true
    rescue LoadError => e
      Rails.logger.info "[INFO] XLSX export feature disabled - #{e.message}"
    end
  end
end

My models using axlsx have

acts_as_xlsx if MY_FEATURE[:gem_axlsx]

... although I think that is not relevant when using axlsx templates - checked and found that without that line I get exactly the same exception

@straydogstudio
Copy link
Collaborator

@swiehr Thanks that will help. I meant what data are you exporting into a spreadsheet.

This error has cropped up here and there, and I have never been able to reproduce it. No one has been able to provide me with a repo. Given that your setup is based on Redmine, it will be easier for me to reproduce the error; then I can find the problem. Whatever information you can give me regarding your plugin will help. Is the plugin one of your repositories?

@swiehr
Copy link
Author

swiehr commented Jun 12, 2018

@straydogstudio Unfortunately the plugin is not (yet) open source (developing this at work so it's not me to decide about that) - from my perception it shouldn't be too difficult to reproduce this as I am simply exporting an index view (i.e. the complete table data) into an xlsx.
Maybe I can write a small dummy plugin that would simply demonstrate this...

@straydogstudio
Copy link
Collaborator

@swiehr I will do a straight export.

An example plugin would help. Or you could sketch out the relevant details in a gist.

@swiehr
Copy link
Author

swiehr commented Jun 12, 2018

@straydogstudio Check my small sample Redmine plugin https://github.com/swiehr/xlsx_export (after installation in Redmine will be available from the admin menu)

@straydogstudio
Copy link
Collaborator

@swiehr Thank you very much. I should get a chance to look at this tomorrow night.

@alanq
Copy link

alanq commented Jan 22, 2020

I also get "No template found" from axlsx_rails 0.5.2 or later (currently caxlsx_rails 0.6.2)
Reverting to 0.5.1 finds the *.xlsx.axlsx tempate.

@alanq
Copy link

alanq commented Jan 23, 2020

I also get "No template found" from axlsx_rails 0.5.2 or later (currently caxlsx_rails 0.6.2)
Reverting to 0.5.1 finds the *.xlsx.axlsx tempate.

This resolved for me by explicitly adding caxlsx_rails in the container app's Gemfile, rather than pulling it in from another gem's gemspec as a runtime_dependency (even though Gemfile.lock is the same either way)

@straydogstudio
Copy link
Collaborator

@alanq Thank you very much Alan. The automatic inclusion of Caxlsx has been brought up in another issue. I'll look into it.

@return-nil
Copy link

I ran into the same problem.
I solved the problem by specifying the formats.

render xlsx: 'hoge', template: 'template', formats: :xlsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants