0
사용자가 가입 할 수 있도록 스트라이프를 사용 중입니다. 거기에서 나는 줄무늬 날짜를 모으고 기부금 형태에서 저장한다. 스트리밍 구독 ID에 다른 역할 기반을 할당하기 위해 내 사용자 모델에 대한 열거 형을 만들었습니다. 내 사용자 모델은레일 컨트롤러에서 레코드를 업데이트하는 방법
class User < ApplicationRecord
enum role: [:user, :gold, :platinum, :diamond ]
has_one :subscription
has_one :shipping
extend FriendlyId
friendly_id :firstname, use: [:slugged, :finders]
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
모양과 울부 짖는 소리가 내 가입 컨트롤러
def subscription_checkout
user = current_user
plan_id = params[:plan_id]
plan = Stripe::Plan.retrieve(plan_id)
# This should be created on signup.
customer = Stripe::Customer.create(
description: 'Customer for [email protected]',
source: params[:stripeToken],
email: '[email protected]'
)
# Save this in your DB and associate with the user;s email
stripe_subscription = customer.subscriptions.create(plan: plan.id)
@sub = Subscription.create(plan: stripe_subscription.plan.name,
stripeid: stripe_subscription.id,
user_id: current_user.id,
customer: stripe_subscription.customer,
subscriptionenddate: stripe_subscription.current_period_end)
if @sub.save
current_user.role plan.id
current_user.save
flash[:success] = 'sub created!'
redirect_to root_url
else
render 'new'
end
end
어떻게 여기 는 역할을 업데이트 도달했을 때 내가
ArgumentError: wrong number of arguments (1 for 0)
를 얻을 수 있습니다 나는를 업데이트 할 수있는 방법 역할과 내가 뭘 잘못하고 있니?
이 작동합니다. 이제'정의되지 않은 메소드'diamond를 얻고 있습니까? ' # true' –
주변 코드는 어디에 있습니까? 오류가 발생하기 전에 디버거를 배치하여 콘솔에 들어가 보았습니까? 아니면 IRB를 열었습니까? – arjabbar