Я пытаюсь экспортировать файл docx, используя caracal, но получаю ошибку маршрутизации, но все вроде бы нормально. Я сделал это 3 дня go точно так же, как сейчас и работал, теперь я получаю ошибку. Routes.rb
Rails.application.routes.draw do
get 'grayscale/index'
devise_for :users, path: '', path_names: {sign_in: 'login', sign_out: 'logout', sign_up: 'registrar'}
resources :contratos
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'contratos#index'
get 'contratos/page'
end
contratos_controller.rb
class ContratosController < ApplicationController
before_action :authenticate_user!
before_action :set_contrato, only: [:show, :edit, :update, :destroy, :export, :page]
access all: [:show, :index], user: {except: [:destroy, :new, :create, :update, :edit]}, site_admin: :all
require './lib/generate_pdf'
# GET /contratos
# GET /contratos.json
def index
@contratos = Contrato.all
end
# GET /contratos/1
# GET /contratos/1.json
def show
end
# GET /contratos/new
def new
@contrato = Contrato.new
end
# GET /contratos/1/edit
def edit
end
def page
Caracal::Document.save(Rails.root.join("public", "example.docx")) do |docx|
# page 1
docx.h1 'Page 1 Header'
docx.hr
docx.p
docx.h2 'Section 1'
docx.p 'Lorem ipsum dolor....'
docx.p
end
path = File.join(Rails.root, "public")
send_file(File.join(path, "example.docx")
end
show. html .erb
<%= link_to 'Generate Docx', contratos_page_path %>
Полная ошибка
ActiveRecord::RecordNotFound in ContratosController#show
Couldn't find Contrato with 'id'=page
def set_contrato
@contrato = Contrato.find(params[:id])
end