0
我在我的rails應用程序中使用strong_parameters和devise_invitable。如果我離開它,因爲它是「禁止屬性」運行時錯誤是我得到的。所以,我做了以下內容:如何解決「邀請令牌不能爲空」的DeviseInvitable
- 創建使用
rails g controller users/invitations
- 新增
:invitations => "users/invitations"
一個新的控制器,以devise_for 填充的用戶/ invitations.rb像這樣:
class Users::InvitationsController < Devise::InvitationsController def update self.resource = resource_class.accept_invitation!(allowed_params) if resource.errors.empty? set_flash_message :notice, :updated sign_in(resource_name, resource) respond_with resource, :location => after_accept_path_for(resource) else respond_with_navigational(resource){ render :edit } end end private def allowed_params params.permit(:utf8,:authenticity_token,:invitation_token, :_method, {user: [:invitation_token,:password,:password_confirmation]}, :commit, :action,:controller) end end
然而,當我這樣做時,我得到錯誤「邀請令牌不能爲空」。我檢查了allowed_params的值,使用puts
,它似乎在那裏。但是,我仍然得到錯誤。
太棒了!這完美的作品!謝謝 ! –