[Introduction to Rails] How to use render

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

Recommended Posts

[Introduction to Rails] How to use render
[Rails] How to use enum
[Rails] How to use enum
How to use rails join
[Rails] How to use validation
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[Rails] How to use Scope
[Rails] How to use gem "devise"
[Rails] How to use flash messages
How to use Ruby on Rails
[Rails] How to use Active Storage
How to use custom helpers in rails
[Ruby on Rails] How to use CarrierWave
[Rails] How to use rails console with docker
[Rails] How to use ActiveRecord :: Bitemporal (BiTemporalDataModel)
[Rails] How to use the map method
How to use MySQL in Rails tutorial
[Ruby on Rails] How to use redirect_to
[Note] How to use Rails 6 Devise + cancancan
[Ruby on Rails] How to use kaminari
[Rails] How to use video_tag to display videos
[Rails] How to use helper method, confimartion
How to use credentials.yml.enc introduced in Rails 5.2
How to write Rails
How to use rbenv
How to use letter_opener_web
How to use with_option
How to use java.util.logging
How to use map
How to use Twitter4J
How to use active_hash! !!
How to use hidden_field_tag
How to uninstall Rails
[How to use label]
How to use identity
How to use hashes
How to use JUnit 5
How to use Dozer.mapper
How to use Gradle
How to use org.immutables
How to use java.util.stream.Collector
How to use VisualVM
How to use Map
[Rails] Introduction of pry-rails ~ How to debug binding.pry
[Rails] How to use select boxes in Ransack
How to use rails g scaffold, functions, precautions
How to use enum (introduction of Japanese notation)
How to use JQuery in js.erb of Rails6
[Rails] How to use Gem'rails-i18n' for Japanese support
[Rails] How to use PostgreSQL in Vagrant environment
[Java] How to use Map
[rails] How to post images
How to use Chain API
[Java] How to use Map
How to use Priority Queuing
How to use java Optional
How to use JUnit (beginner)
How to use Ruby return
[Rails] How to install devise
How to read rails routes