简体   繁体   中英

How to redirects from one page to another in ruby on rails

I am using ruby on rails devise . I made a 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.

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.

You can see all routes with rails routes command. You can find more detail for devise sign_in, sign_up and sign_out links in the following link:

https://github.com/plataformatec/devise/wiki/How-To:-Add-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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM