【发布时间】:2018-08-21 14:14:34
【问题描述】:
编辑#1
查看订单/显示,我还没有添加发票,但视图应该可以使用或不使用发票链接,对吧?
<section class="pt-4 px-8 animated">
<section class="flex flex-wrap justify-between">
<h3 class="font-normal text-grey-dark mb-4 py-2">Order Information</h3>
<%= render 'layouts/dashboard/account' %>
</section>
<h2 class="text-grey-darkest text-lg no-underline py-4">
Course: <%= @order.course.title %>
</h2>
<section class="py-2">
<p class="text-grey-darkest text-md pb-4"><%= @order.course.description %></p>
<p class="text-grey-darkest text-md">
<b>Course Price:</b>
£<%= @order.course.price %>
</p>
<p class="text-grey-darkest text-md">
<b>Total Price:</b>
£<%= @order.amount %>
</p>
</section>
<section class="text-grey-darkest pt-4">
<h4 class="pb-2">User details</h4>
<p>Name: <%= current_user.full_name %></p>
<p>Email: <%= current_user.email %></p>
</section>
</section>
原始问题
我的控制器出现ActionController::UnknownFormat 错误
class OrdersController < ApplicationController
layout proc { user_signed_in? ? "dashboard" : "application" }
before_action :authenticate_user!
def index
@orders = Order.includes(:course).all
end
def show
@order = Order.find(params[:id])
respond_to do |format|
format.pdf {
send_data @order.receipt.render,
filename: "#{@order.created_at.strftime("%Y-%m-%d")}-aurameir-courses-receipt.pdf",
type: "application/pdf",
disposition: :inline
}
end
end
def create
end
def destroy
end
end
我正在使用 https://github.com/excid3/receipts gem,它使用 prawn,但我不确定为什么会出现错误。
【问题讨论】:
-
您能否提供包含显示操作链接的视图?
-
查看编辑#1 @IgorDrozdov
-
所以您尝试在浏览器中输入网址然后收到此错误消息?
-
所以我要去订单localhost:3000/orders/1 并得到错误
标签: ruby-on-rails ruby ruby-on-rails-5