简体   繁体   English

如何在Rails中的红宝石中从一页重定向到另一页

[英]How to redirects from one page to another in ruby on rails

I am using ruby on rails devise . 我正在使用ruby在rails devise上 I made a login_controller. 我做了一个login_controller。

class LoginController < ApplicationController
    def homepage
    end
end

Action page 动作页面

<div class="tab">
        <%= button_to "Sign Up", root_url, :method => :get, :form_class => "link" %>
        <%= button_to "Log In", root_url, :method => :get, :form_class => "link" %>
    </div> 

I know I have to replace "root_url" but dont know with which url. 我知道我必须替换“ root_url”,但不知道使用哪个url。

routes.rb 的routes.rb

Rails.application.routes.draw do
  #devise_for :users
  root "login#homepage"
  devise_for :users, controllers: { sessions: 'users/sessions' }
end

So I want to get redirect to login pages when user clicks "Sign Up" button. 因此,当用户单击“注册”按钮时,我想重定向到登录页面。 I searched many questions on stackoverflow but didnt get the desired one. 我搜索了许多关于stackoverflow的问题,但没有得到想要的问题。

You can see all routes with rails routes command. 您可以使用rails routes命令查看所有路由。 You can find more detail for devise sign_in, sign_up and sign_out links in the following link: 您可以在以下链接中找到有关设计sign_in,sign_up和sign_out链接的更多详细信息:

https://github.com/plataformatec/devise/wiki/How-To:-Add-sign_in,-sign_out,-and-sign_up-links-to-your-layout-template https://github.com/plataformatec/devise/wiki/操作方法:-添加-sign_in,-sign_out,-and-sign_up-links-to-your-layout-template

<div class="tab">
    <%= button_to "Sign Up", new_user_registration_path, :method => :get, :form_class => "link" %>
    <%= button_to "Log In", new_user_session_path, :method => :get, :form_class => "link" %>
</div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ruby on Rails:如何使用不同的控制器从一个视图/页面链接/路由到另一个视图/页面 - Ruby on Rails: How to link/route from one view/page to another view/page with a different controller 在Ruby on Rails中将一页移到另一页? - Move one page to another in Ruby on rails? 如何将ID从一张桌子存储到另一张桌子上的红宝石在Rails 2上 - How to store the id from the one table to another in ruby on rails 2 Ruby / Rails如何创建从一个视图到另一视图的链接 - Ruby/Rails How to create link from one view to another view Ruby on Rails:如何将对象从一个类别复制到另一个类别 - Ruby on Rails: how to copy objects from one category to another Ruby on Rails:删除重定向到显示页面的链接 - Ruby on Rails: Delete link to redirects to show page Ruby on Rails 4,如何在另一个页面中显示用户 - Ruby on Rails 4, How to Display User in Another page 如何正确处理将不良网址重定向到Rails中的ruby中的自定义404页面? - How do I correctly handle redirects for bad url's to custom 404 page in ruby on rails? 重定向到Ruby on Rails中的另一个页面 - Redirect to another page in Ruby on Rails Ruby on Rails:如何通过用户界面中的按钮将特定/选择的记录从一个表(用户)发送到另一个表 - Ruby on Rails: How to send a specific/chosen record from one table (User) to another with a button from user interface
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM