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

Error when trying to save documents with Caracal on Production environment #13

Open
MaiconMares opened this issue Oct 24, 2022 · 1 comment

Comments

@MaiconMares
Copy link

Dear Mr. John Dugan. I am not able to generate documents on production environment on Heroku. I've created a helper that is called from a view and generate my document. On development environment, in my local puma server, all works fine, but after I've deployed my app on Heroku and tryed to save the document nothing happens! Thank you for your time!!!

  • My helper method to generate docx file:
module DrawMapsHelper
  def build_map_document(draw_map)
    filename = "meu_mapa_#{DateTime.now.to_s}.docx"
    Caracal::Document.save "#{filename}" do |docx|
      docx.p 'Estudo Numerológico Pessoal' do
        color 'd11a11'
        size 24
        bold true
        align 'center'
      end

      docx.p '(Mapa Numerológico)' do
        color 'd11a11'
        size 24
        bold true
        align 'center'
        br
      end

      docx.p 'Índice' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
      end

      draw_map.index.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.page
      docx.p 'Orientação' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.guidance_preface do
        color '000000'
        size 18
        italic true
        align 'both'
        br
        br
      end

      docx.p draw_map.guidance_explanation do
        color '000000'
        size 18
        align 'both'
        br
      end

      docx.p 'Importante' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.guidance_warning.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.page
      docx.p 'Os seus Números' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.your_numbers.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.page
      docx.p 'Motivação' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.motivation_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      docx.p draw_map.motivation.split("\n")[0] do
        color '000000'
        bold true
        size 22
        br
      end

      draw_map.motivation.split("\n")[1..-1].each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.page
      docx.p 'Impressão' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.impression_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      docx.p draw_map.impression.split("\n")[0] do
        color '000000'
        bold true
        size 22
        br
      end

      draw_map.impression.split("\n")[1..-1].each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.page
      docx.p 'Expressão' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.expression_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      docx.p draw_map.expression.split("\n")[0] do
        color '000000'
        bold true
        size 22
        br
      end

      draw_map.expression.split("\n")[1..-1].each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.page
      docx.p 'Cores que melhor se harmonizam com seu Dia de Nascimento' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.colors_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      draw_map.colors.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.page
      docx.p 'Destino' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.destiny_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      docx.p draw_map.destiny.split("\n")[0] do
        color '000000'
        bold true
        size 22
        br
      end

      draw_map.destiny.split("\n")[1..-1].each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.page
      docx.p 'Missão' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.mission_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      docx.p draw_map.mission.split("\n")[0] do
        color '000000'
        bold true
        size 22
        br
      end

      draw_map.mission.split("\n")[1..-1].each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Seu Anjo' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.angel.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Lições Cármicas' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.karmic_lessons_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      docx.p draw_map.karmic_lessons.split("\n")[0] do
        color '000000'
        bold true
        size 22
        br
      end

      draw_map.karmic_lessons.split("\n")[1..-1].each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.page
      docx.p 'Dívidas Cármicas' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.karmic_debts_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      draw_map.karmic_debts.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Tendências Ocultas' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.hidden_trends_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      draw_map.hidden_trends.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.page
      docx.p 'Resposta Subonsciente' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.subconscious_response_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      docx.p draw_map.subconscious_response.split("\n")[0] do
        color '000000'
        bold true
        size 22
        br
      end

      draw_map.subconscious_response.split("\n")[1..-1].each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.page
      docx.p 'Ciclos de Vida' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.life_cycles_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      draw_map.first_life_cycle.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      draw_map.second_life_cycle.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      draw_map.third_life_cycle.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.page
      docx.p 'Desafios' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.challenges_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      docx.p 'Primeiro Desafio' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.first_challenge.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Segundo Desafio' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.second_challenge.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Desafio Principal' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.main_challenge.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.page
      docx.p 'Momentos Decisivos' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.decisive_moments_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Primeiro Momento Decisivo' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.first_decisive_moment.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Segundo Momento Decisivo' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.second_decisive_moment.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Terceiro Momento Decisivo' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.third_decisive_moment.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Quarto Momento Decisivo' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.fourth_decisive_moment.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.page
      docx.p 'Número Psíquico' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.psychic_number_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      docx.p draw_map.psychic_number.split("\n")[0] do
        color '000000'
        bold true
        size 22
        br
      end

      draw_map.psychic_number.split("\n")[1..-1].each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Ano Pessoal' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.personal_year_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      draw_map.personal_years.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Mês Pessoal' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.personal_months_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
      end

      draw_map.personal_months.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Dia Pessoal' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.personal_days_explanation.split("\n") do |line|
        docx.p line do
          color '000000'
          size 18
          italic true
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Dias do Mês Favoráveis' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.favorable_months_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      draw_map.favorable_months.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end

      docx.page
      docx.p 'Números Harmônicos' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.harmonic_numbers_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      draw_map.harmonic_numbers.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.p do
        text ''
        br
      end

      docx.p 'Harmonia Conjugal' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.marital_harmony_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
        br
      end

      draw_map.marital_harmony.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.page
      docx.p 'Triângulo da Vida' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.life_triangle_explanation do
        color '000000'
        size 18
        align 'both'
        italic true
      end

      docx.p do
        text ''
        br
      end

      draw_map.life_triangle.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 20
          align 'both'
        end
      end

      docx.page
      docx.p 'Conclusão' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.conclusion.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.page
      docx.p 'Significado dos Arcanos' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      docx.p draw_map.arcanes_meaning.split("\n")[0] do
        color '000000'
        bold true
        size 22
        br
      end

      draw_map.arcanes_meaning.split("\n")[1..-1].each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'left'
        end
      end

      docx.page
      docx.p 'Numerologia Cabalística' do
        color 'd11a11'
        size 24
        bold true
        align 'left'
        br
      end

      draw_map.cabalistic_numerology.split("\n").each do |line|
        docx.p line do
          color '000000'
          size 18
          align 'both'
        end
      end
    end
  end
end
@jdugan
Copy link
Contributor

jdugan commented Oct 25, 2022

I'm not much of a maintainer anymore—and truthfully should cede the project to someone else—but I believe the issue you're having stems from using the save method. This will try to write the output to the file system, which you would not have in Heroku.

I'm working from deep memory here, but I think Caracal::Document has a render function that will return the document as a string, which you can handle however you like.

And, finally, if this is a Rails app, there is a separate gem that was designed to pipe out the document from a controller. I honestly don't know if that still functions, but it might. At the very least, it would point you in the right direction. The plugin itself was just a tiny wrapper. :)

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

2 participants