karnov / htmltoword

Ruby html to word gem
MIT License
179 stars 71 forks source link

Use a template from another directory #62

Open galievruslan opened 7 years ago

galievruslan commented 7 years ago

Hello

I'm using the version of htmltoword 0.5.1

My controller code

class ReportsController < ApplicationController
  respond_to :docx
  def run
    @report = Report.find(params[:id])
  end

  def execute
    @report = Report.find(params[:id])
    @params = params
    @user = current_user
    if @report.format == 'html'
      render @report.template.path
    elsif @report.format == 'docx'
      file_name = @report.name + '.' + @report.format
      render docx: @report.template.path, filename: file_name
    elsif @report.format == 'xlsx'
      file_name = @report.name + '.' + @report.format
      render file: @report.template.path
    end
  end
end

Reports are created and their templates are downloaded with carrierwave to the folder /uploads/report_templates/13/REPORT_NAME

But if I use the code I wrote above, then the application gives an error 404. Tell me how it can be fixed or bypassed?

deepak496 commented 6 years ago

My problem is that it is not picking a single css whether defined externally or even inline. Can anybody tell me do we need to do something else as well apart from including the gem in the gemfile. What are the steps to successfully implementing docx with proper css