这是第一次使用devise_invitable gem ,没有错误,也没有发送电子邮件
projects_controller.rb
def add_admin
@email = :email
User.invite!(:email => @email, :project => current_user.project)
end
视图/项目/ show.html.erb
<% if @project == current_user.project %>
<% @user = User.new %>
<%= "you can add admin to " + @project.project_name %>
<p> please type his email </p>
<%= form_for @user, url: {controller: "projects", action: "add_admin"} do |f| %>
<%= f.email_field "email" %>
<%= f.submit "Invite" %>
<% end %>
<% end %>
的routes.rb
post "/projects/add_admin"
答案 0 :(得分:0)
最后我发现了
方法应该是
def add_admin
User.invite!(:email => params[:user][:email], :ProjectId => current_user.project.id)
end