注册并直接登录轨道3设计?

问题描述:

我有一个注册机制,通过确认链接激活后完成。现在我想删除可确认的,我希望用户在注册后直接登录。请告诉我需要做些什么改变,我该如何做?我是否也需要从数据库中删除确认字段?请告诉我整个过程。注册并直接登录轨道3设计?

在将用户保存到db之前,您需要使用@user.skip_confirmation!。 如果你使用的是registration_controller,那么@user对象就像资源一样。

这是registrations_controller的创建方法。

def create 
    build_resource 
    resource.skip_confirmation! 
    if resource.save 
     if resource.active_for_authentication? 
     set_flash_message :notice, :signed_up if is_navigational_format? 
     sign_in(resource_name, resource) 
     respond_with resource, :location => redirect_location(resource_name, resource) 
     else 
     set_flash_message :notice, :inactive_signed_up, :reason => inactive_reason(resource) if is_navigational_format? 
     expire_session_data_after_sign_in! 
     respond_with resource, :location => after_inactive_sign_up_path_for(resource) 
     end 
    else 
     clean_up_passwords(resource) 
     respond_with_navigational(resource) { render_with_scope :new } 
    end 
    end 
+0

它的工作原理,但我不想因为我不是冻结在registeration的控制人变更设计宝石,是否有任何其他方式,以便我可以从我的应用程序中删除可确认? –

+0

其他可能的解决方案是:你可以从user.rb模型中删除可确认的。然后删除数据库 - 创建数据库 - 然后迁移和C无论代码工作与否... –

只需从用户模型中删除可确认的模块。

devise :confirmable, … 
+0

以及我已经做了这一点,但它不工作,即使是现在我的注册页面未签约..... –