의 ActiveRecord :: RecordNotFound 저는 생각하는 법을 배우는 것에 완전히 익숙하지 않고, 문제에 부딪쳐서 레일스 튜토리얼 스트라이프를 따라 가면 안 될 것 같습니다. 내가 언급 한 것처럼, 나는 생각하는 법을 배우는 것에 아직 익숙하지 않고, 코드를 복사하고 붙여 넣지 않고 읽는 것,보고, 쓰지 만 튜토리얼을 따르고 있기 때문에 정확히 무엇이 엉망인지 알아낼 수 없다. 근육 기억을 구축하기 위해 밖으로. 아마 철자법 오류, 그러나, 나는 이중 검사. 시간 내 줘서 고마워.TransactionsController # new
class TransactionsController < ApplicationController
skip_before_action :authenticate_user!, only: [:new, :create]
def new
@product = Product.find_by!(
permalink: params[:permalink]
)
end
def pickup
@sale = Sale.find_by?(guid: params[:guid])
@product = @sale.product
end
def create
@product = Product.find_by!(
permalink: params[:permalink]
)
token = parmas[:stripeToken]
begin
charge = Stripe::Charge.create(
amount: product.price,
currency: "usd",
card: token,
description: params[:stipeEmail]
)
@sale = product.sales.create!(
email: params[:stripeEmail],
stripe_id: charge.id
)
redirect_to pickup_url(guid: @sale.guid)
rescue Stripe::CardError => e
# the card has been declined or
# some other error has occured
@error = e
render :new
end
end
def download
@sale = Sale.find_by!(guid: params[:guid])
resp = HTTParty.get(@sale.product.file.url)
filename = @sale.product.file.url
send_data resp.body,
:filename => File.basename(filename),
:content_type => resp.headers['Content-Type']
end
end
오류는 어디에 있습니까? 정확한 오류 역 추적 및 메시지를 표시하십시오. –
하단의 [link] (https://www.masteringmodernpayments.com/read/basic_integration) 지침에 따라 [링크] (http : // localhost : 3000/buy/some_permalink)와 액션 컨트롤러 오류에 따르면,이 줄은 '@product = Product.find_by!'(' – Justin