I have created an invitation controller that is quite vanilla:
class InvitationsController < Devise::InvitationsController
def new
binding.pry
end
end
And I created a link that triggers that request like so:
<%= link_to "Invite #{@profile.name}", new_user_invitation_path(email: @profile.email), class: "btn btn-xs btn-primary" %>
The issue I am having is that when I get thrown into pry in that action, it doesn't show me that email
parameter.
> params
=> <ActionController::Parameters {"controller"=>"invitations", "action"=>"new"} permitted: false>
How can I send params with that InvitationsControler#New
action?
It turns out that new_user_invitation_path
corresponds to a GET
request to a new invitation object, which generates a new form.
The solution is to create another action in another controller then simply call it with a method: :post
like so:
<%= link_to "Invite #{@profile.name}", invite_path(@profile), method: :post, data: { confirm: "Are you SURE you are ready to invite #{@profile.name}?"}, class: "btn btn-xs btn-primary" %>
That works like a charm.