1

我将 RegistrationsController 子类化,以便可以使用 Stripe 构建付款表单。我已将 Stripe 代码放在 create 方法中,当我注册时,它会毫无问题地创建 Stripe 客户。但是,注册完成后我没有登录,因为我无法登录,所以没有创建用户。

代码如下(我省略了 Stripe 代码,因为它似乎不相关,但如果需要我可以发布它)。

    build_resource
resource.role = params[:selectplan]
resource.admin = false 
resource.customer_id = customer.id
if resource.save
  Notifier.signup_email(@user).deliver
  if resource.active_for_authentication?
    set_flash_message :notice, :signed_up if is_navigational_format?
    sign_in(resource_name, resource)
    respond_with resource, :location => after_sign_up_path_for(resource)
  else
    set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
    expire_session_data_after_sign_in!
    respond_with resource, :location => after_inactive_sign_up_path_for(resource)
  end
else
  clean_up_passwords resource
  respond_with resource
end  
4

1 回答 1

1

该资源没有保存,因为我仍在使用 Rails 4 和 Devise 不支持的 attr_accessible。我切换到使用强参数,现在它又可以正常工作了。

于 2013-10-28T11:03:36.777 回答