任何人都有devise_invitable的经验? [英] Anyone have experience with devise_invitable?

查看:122
本文介绍了任何人都有devise_invitable的经验?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何添加在控制器中使用devise_invitable的功能。我想要添加消息,proeject_id等附加字段以及邀请,但不知道从哪里开始?

How can you add the ability to use devise_invitable in the controller. I wan to add additional fields like message, proeject_id along with the invitation but have no idea where to start?

这里是devise_invitable:链接文本

Here's devise_invitable: link text

推荐答案

devise_inevitable引擎定义了两个视图文件和一个控制器。您更可能不需要对其定义的控制器执行任何修改。向用户发送邀请的表单定义为这里,您将覆盖视图的呈现,如下所示:

The devise_inevitable engine defines two view files and one controller. You more than likely do not need to perform any modifications to the controller that it defines. The form that sends invitations to users is defined here and you would override the rendering of the view like so:

#app/views/invitations/new.html.erb
<% form_for resource_name, resource, :url=> invitation_path(resource_name) do |f| %>
  <!-- Totally sweet new user invitation code goes here -->
<% end %>

包含用户在他们的电子邮件上点击链接后完成注册的代码的表单是这里,你将覆盖渲染如下所示:

The form that contains the code for users to complete registration after clicking the link on their email is here and you would override the rendering of it like so:

#app/views/invitations/edit.html.erb
<% form_for resource_name, resource, :url=> invitation_path(resource_name), :html=>{:method => :put } do |f| %>
  <!-- Totally sweet new user registration information goes here. -->
<% end %>

第一个视图是实际创建资源对象的内容,因此,我想要设置一个消息供用户查看,他们被邀请的是什么项目。您可能还想覆盖应用/视图/devise_mailer/invitation.html.erb 更改用户收到的电子邮件。

The first view is what will actually create the resource object, so that is more than likely where you'll want to be setting a message for the user to see, what project they are invited to as well. You might also want to override app/views/devise_mailer/invitation.html.erb to change the email message the user receives.

为了覆盖邀请控制器,您需要执行此操作:

In order to override the invitations controller you'd need to do this:

#app/controllers/devise/invitations_controller.rb
class Devise::InvitationsController < ApplicationController
  def create
    #totally rad create stuff here.
  end
end

Devise及其扩展名都是Rails引擎,所以请求将首先在您的应用程序目录中找到一个适当的controller / model / view / helper文件,然后在vendor / gem中找到,然后再在定义引擎的gem目录中找到。

Devise and its extensions are all Rails engines, so the request will first look for an appropriate controller/model/view/helper file in your app directory, then in vendor/gems, and then finally in the gem directory that defines the engine.

这篇关于任何人都有devise_invitable的经验?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆