Я использую devise_invitable gem в моем приложении rails 5. Каждый раз после отправки кнопки «Отправить приглашение» я получаю сообщение об ошибке RuntimeError в Devise :: InvitationsController # create, не удалось найти допустимое сопоставление для nil
Вот код application_controller.rb файл:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
def authenticate_inviter!
unless current_user.role=='Manager'
if current_user.role == "Developer"
redirect_to root_path, :alert => "Access Denied! Only Manager Can Add New Developer"
end
super
end
end
protected
def configure_permitted_parameters
added_attrs = [ :email, :password, :password_confirmation ]
devise_parameter_sanitizer.permit :sign_up, keys: added_attrs
devise_parameter_sanitizer.permit :account_update, keys: added_attrs
devise_parameter_sanitizer.permit :accept_invitation, keys: [:email]
end
end
Вот код User.rb:
class User < ApplicationRecord
include DeviseInvitable::Inviter
devise :invitable, :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
end
Вот Route.rb
Rails.application.routes.draw do
devise_for :users
root 'dashboard#index'
end
Вот все маршруты :
Prefix Verb URI Pattern Controller#Action
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
user_password PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
POST /users/password(.:format) devise/passwords#create
cancel_user_registration GET /users/cancel(.:format) devise_invitable/registrations#cancel
new_user_registration GET /users/sign_up(.:format) devise_invitable/registrations#new
edit_user_registration GET /users/edit(.:format) devise_invitable/registrations#edit
user_registration PATCH /users(.:format) devise_invitable/registrations#update
PUT /users(.:format) devise_invitable/registrations#update
DELETE /users(.:format) devise_invitable/registrations#destroy
POST /users(.:format) devise_invitable/registrations#create
accept_user_invitation GET /users/invitation/accept(.:format) devise/invitations#edit
remove_user_invitation GET /users/invitation/remove(.:format) devise/invitations#destroy
new_user_invitation GET /users/invitation/new(.:format) devise/invitations#new
user_invitation PATCH /users/invitation(.:format) devise/invitations#update
PUT /users/invitation(.:format) devise/invitations#update
POST /users/invitation(.:format) devise/invitations#create
root GET / dashboard#index
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
- Я не создавал никаких настраиваемых контроллеров приглашений.
Я просто запустил следующее, чтобы установить и настроить devise_invitable
gem ' devise_invitable '
bundle install
rails generate devise_invitable: install
rails generate devise_invitable User
rails db: migrate
rails generate devise_invitable : views
перезапустите сервер rails
Вот изображение полной ошибки: см. картинку полной ошибки
Как мне избавиться от этой проблемы. Пожалуйста, помогите мне