I installed devise-invitable and using the standard devise-invitable controller (which I didn't generate) it functions properly. However, when I tried generating a custom controller for devise-invitable, I encountered some issues. Please find below the steps I took.
Steps I took to generate the controller
rails generate devise:controllers users -c=invitations
Running via Spring preloader in process 64830
Could not find "invitations_controller.rb" in any of your source paths. Your current source paths are:
/Users/name/code/name/app/lib/templates/devise/controllers
/Users/name/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/devise-4.7.0/lib/generators/templates/controllers
=> This didn't seem to work either, because I tried breaking the controller to see if it was reached, but it doesn't break.
controllers/users/invitations_controller.rb
class Users::InvitationsController < Devise::InvitationsController
def new
@hotel = Hotel.find(params[:park_id])
@user = User.new
@user.hotel = @hotel
text to cause an error message
end
end
routes.rb
Rails.application.routes.draw do
devise_for :users, controllers: {
sessions: 'users/invitations'
}
The problem is in your routes since an invitation is not an session.
If you changes sessions to invitations in your routes then it will hit the users/invitations controller.
# routes.rb
Rails.application.routes.draw do
devise_for :users, controllers: {
invitations: 'users/invitations'
}
end