Ruby on rails 设计登记表

Ruby on rails 设计登记表,ruby-on-rails,ruby,ruby-on-rails-3,devise,Ruby On Rails,Ruby,Ruby On Rails 3,Devise,我的Ruby on rails站点中使用了两个设计表单…如何为这两个设计表单设置不同的路由路径..我试图覆盖after_sign_up_path..但这两个表单都被重定向到同一路径 我想为每个表单设置不同的路径 注册控制器 class Registrations Controller < Devise::Registrations Controller protected def after_sign_up_path_for(resource) 'root_path'

我的Ruby on rails站点中使用了两个设计表单…如何为这两个设计表单设置不同的路由路径..我试图覆盖after_sign_up_path..但这两个表单都被重定向到同一路径

我想为每个表单设置不同的路径

注册控制器

class Registrations Controller < Devise::Registrations Controller
  protected

  def after_sign_up_path_for(resource)
    'root_path'
  end
end
类注册控制器<设计::注册控制器
受保护的
注册后的def路径(资源)
“根路径”
结束
结束

此方法在注册成功时调用,因此请在此处设置注册后的路径

 def after_sign_up_path_for(resource)
      if resource.invitation_type == "first" (please replace with actual invitation type here)
        user1_path(replace with actual path) 
      elsif resource.invitation_type == "second" (please replace with actual invitation type here)
       user2_path(replace with actual path)
      else
        root_path
      end
    end

希望这有帮助

在应用程序控制器中,将“注册后”的代码“路径”的代码“路径”

#put these code inside applications_controller
def after_sign_up_path_for
   if #{your_specific_condition}

   else
    root_path
   end
end

您必须意识到,如果要覆盖注册控制器,您必须:


是指用户成功注册后,您想将其重定向到不同的路由?是的,注册后需要重定向到不同的路由OK这两种类型的用户之间有什么区别??我的意思是,你可以在注册后根据用户类型或你拥有的东西重定向。是的,根据用户类型。我需要在注册后重定向欢迎页面。请在下面检查我的答案。什么是资源。类型?你如何在数据库中存储用户类型?包含用户类型的字段的名称是什么?邀请类型..用户类型基于数据库中存储的邀请类型更新了我的答案…请根据邀请类型进行检查,并相应重定向。
#config/routes.rb
devise_for :users, :controllers => {:registrations => "registrations"}