0
0

More than 3 years have passed since last update.

【Rails入門】renderの使い方

Posted at

rendearの使い方

renderメソッドを用いることで、別のアクションを経由せずに、直接ビューを表示することができます。
render("フォルダ名/ファイル名")のように表示したいビューを指定します。
renderメソッドを使うと、redirect_toメソッドを使った場合と違い、そのアクション内で定義した@変数をビューでそのまま使うことができます。

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

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0