[Ruby] [Introduction to Rails] How to use render

less than 1 minute read

How to use rendear

By using the render method, you can display the view directly without going through another action.
Specify the view you want to display, such as ** render (“folder name / file name”) **.
If you use the render method, you can use the @variable defined in the action as it is in the view, unlike the case of using the redirect_to method.

user_controller.rb


class UserController < ApplicationController
  def top
    @user = User.find_by(email: params[:email], password: params[:password])
    if @user

    else
      render ("home/signup")
    end

  end
end