I just started with Rails and devise and I have a task, allow users to sign up only by invitation of existing user. I choose devise-invitable gem and got stuck with a bit unclear documentation. I have this code:
def invitationForm
@nuser = User.new
end
def invite_user
@user = User.invite!({:email => @nuser.email}, current_user)
end
Where invitationForm
renders a form:
<%= form_for @nuser, url: {action: "invite_user"} do |f| %>
<%= f.text_field :email %>
<%= f.submit "Invite" %>
<% end %>
After all I`m getting this error:
RuntimeError in User#invite
Showing //invite.html.erb where line #2 raised:
Could not find a valid mapping for nil
What am I doing wrong and what should I do?