邀请控制器
class InvitationsController < Devise::InvitationsController
def new
end
def create
end
end
路线.rb
devise_for :users, :controllers => { :invitations => 'users/invitations' }
应用程序控制器
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
# Only add some parameters
devise_parameter_sanitizer.for(:accept_invitation).concat [:email]
# Override accepted parameters
devise_parameter_sanitizer.for(:accept_invitation) do |u|
u.permit(:email, :password, :password_confirmation,
:invitation_token)
end
end
users_controller
def new
@user = User.new(:invitation_token => params[:invitation_token])
@user.email = @user.invitation.recipient_email if @user.invitation
end
当我转到“/users/invitation/new”时,我收到错误“未初始化的常量用户”。我错过了什么?谢谢