我正在尝试使用 devise 和 rails 4 将参数从 user#new 传递给 user#create,但我无法弄清楚。我只想获得@invitation,以便在创建用户后对其进行编辑。
class RegistrationsController < Devise::RegistrationsController
def new
@invitation = Invitation.find_by_invite_token(params[:invite_token])
redirect_to root_url if @invitation.nil
super
end
def create
@invitation = Invitation.find_by_invite_token(params[:invite_token])
# Devise create stuff:
build_resource(sign_up_params)
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
respond_with resource, :location => after_sign_up_path_for(resource)
else
...
@invitation 在用户#create 中为零