Ruby on rails 在设计注册表格后需要重定向到其他表格

Ruby on rails 在设计注册表格后需要重定向到其他表格,ruby-on-rails,ruby,devise,Ruby On Rails,Ruby,Devise,我是ror新手..我使用DeVICE创建了一个表单..注册表单正在工作..值也保存在db中,但保存后会重定向到用户页面…是否有任何方法更改它…我希望在用户提交表单后链接另一个表单 控制器 class UserRequestsController

我是ror新手..我使用DeVICE创建了一个表单..注册表单正在工作..值也保存在db中,但保存后会重定向到用户页面…是否有任何方法更改它…我希望在用户提交表单后链接另一个表单

控制器

class UserRequestsController
应用程序助手

def资源名称
:用户
结束
def资源
@资源| |=User.new
结束
def设计映射
@设计映射| |=设计映射[:用户]
结束
型号

class UserRequest < ActiveRecord::Base
  belongs_to :user

  validates :user_id, :email, :name, :invitation_type, presence: true
  validates :email, uniqueness: true
  validates :email, email: true
  validate :email_not_in_use_already
  validate :invitation_type_is_valid

  def email_not_in_use_already
    if new_record? && User.where(email: self.email).any?
      errors.add(:email, "is already in use")
    end
  end

  def invitation_type_is_valid
    unless INVITATION_TYPES.include?(self.invitation_type)
      errors.add(:invitation_type, "is not a valid type of invitation")
    end
  end
end
classuserrequest
应用程序控制器

class ApplicationController

需要重定向到另一个控制器操作…请给出修复该操作的方法。

您只需要在此处指定路径名。更改:

def after_sign_up_path_for(resource)
    root to: "vendors#invited_new", as: :manager_root
end
致:

阅读:


您只需要在那里指定路径名。更改:

def after_sign_up_path_for(resource)
    root to: "vendors#invited_new", as: :manager_root
end
致:

阅读:


您只需要在那里指定路径名。更改:

def after_sign_up_path_for(resource)
    root to: "vendors#invited_new", as: :manager_root
end
致:

阅读:


您只需要在那里指定路径名。更改:

def after_sign_up_path_for(resource)
    root to: "vendors#invited_new", as: :manager_root
end
致:

阅读:


您可以覆盖您的设计注册控制器

class RegistrationsController < Devise::RegistrationsController

  ##this method calls when signup is success
    def after_sign_up_path_for(resource)
      if put your condition here
        your_redirect_path (replace your different controller path here)
      else
        root_path
      end
    end 

end

您可以覆盖您的设计注册控制器

class RegistrationsController < Devise::RegistrationsController

  ##this method calls when signup is success
    def after_sign_up_path_for(resource)
      if put your condition here
        your_redirect_path (replace your different controller path here)
      else
        root_path
      end
    end 

end

您可以覆盖您的设计注册控制器

class RegistrationsController < Devise::RegistrationsController

  ##this method calls when signup is success
    def after_sign_up_path_for(resource)
      if put your condition here
        your_redirect_path (replace your different controller path here)
      else
        root_path
      end
    end 

end

您可以覆盖您的设计注册控制器

class RegistrationsController < Devise::RegistrationsController

  ##this method calls when signup is success
    def after_sign_up_path_for(resource)
      if put your condition here
        your_redirect_path (replace your different controller path here)
      else
        root_path
      end
    end 

end

1。创建一个新的控制器“registrations\u controller.rb”,并自定义适当的方法:

class RegistrationsController < Devise::RegistrationsController
  protected

  def after_sign_up_path_for(resource)
    '/an/example/path' # Or :prefix_to_your_route
  end
end
可选地复制视图

注意:在运行Ruby 1.9.2-p290的rails 3.2.5中,似乎没有必要执行以下步骤。您只需创建RegistrationController并更改路线。然后,通过继承designe::RegistrationController,您可以选择现有的designe registrations视图。无论您是否已经使用

rails g devise:views
或者不是

注意:在config/routes.rb文件中更改控制器后,您将希望通过designe注册视图复制到新的app/views/registrations路径

使用“rails生成设备:视图”复制文件。完成此操作后,您需要将views/design/registrations/new.html.erb复制到views/registrations/new.html.erb,否则在转到用户/注册时会出现“缺少模板”错误

3。修改config/application.rb

如果遇到“MissingTemplate”错误,您可能需要这一行 在“/用户/注册”页面中


config.path['app/views']1。创建一个新的控制器“registrations\u controller.rb”,并自定义适当的方法:

class RegistrationsController < Devise::RegistrationsController
  protected

  def after_sign_up_path_for(resource)
    '/an/example/path' # Or :prefix_to_your_route
  end
end
可选地复制视图

注意:在运行Ruby 1.9.2-p290的rails 3.2.5中,似乎没有必要执行以下步骤。您只需创建RegistrationController并更改路线。然后,通过继承designe::RegistrationController,您可以选择现有的designe registrations视图。无论您是否已经使用

rails g devise:views
或者不是

注意:在config/routes.rb文件中更改控制器后,您将希望通过designe注册视图复制到新的app/views/registrations路径

将文件复制到u