Determine the current page with Ruby on Rails

current_page? method

Used in view

# http://hoge.com/Whether it is fuga
current_page?(http://hoge.com/fuga)

# /hoge hoge or not
current_page?(/hogehoge)

# hoge_Whether it is a path
current_page?(hoge_path)

#Whether it is an arbitrary action
current_page?(action: 'new')

#Any controller/Whether it is an action
current_page?(controller: 'hoge', action: 'new')

Recommended Posts

Determine the current page with Ruby on Rails
Publish the app made with ruby on rails
Solve the N + 1 problem with Ruby on Rails: acts-as-taggable-on
Programming with ruby (on the way)
[Ruby on Rails] Confirmation page creation
[Ruby on Rails] Quickly display the page title in the browser
Delete all the contents of the list page [Ruby on Rails]
[Ruby on Rails] View test with RSpec
part of the syntax of ruby ​​on rails
Notes on using FCM with Ruby on Rails
[Ruby on Rails] Controller test with RSpec
[Ruby on Rails] Model test with RSpec
Understand code coverage with Rspec, the Ruby on Rails test framework
[Ruby on Rails] Until the introduction of RSpec
Introducing Rspec with Ruby on Rails x Docker
When the Ruby on Rails terminal rolls back
Ruby on Rails Elementary
Ruby on Rails basics
[Rails] Procedure for linking databases with Ruby On Rails
Ruby On Rails Association
[Ruby on Rails] Upload multiple images with refile
I made a portfolio with Ruby On Rails
[Rails] When transitioning to a page with link_to, move to the specified location on the page
[Ruby on Rails Tutorial] Error in the test in Chapter 3
Docker the development environment of Ruby on Rails project
[Ruby on Rails] Delete s3 images with Active Strage
[Ruby on Rails] How to change the column name
Challenge the settings for developing with vue.js on Rails 6
(Ruby on Rails6) Reflecting the posted content from the form
Created RSS / Atom format sitemap with Ruby on Rails
Try using the query attribute of Ruby on Rails
Ruby on rails learning record -2020.10.03
Portfolio creation Ruby on Rails
Ruby on rails learning record -2020.10.04
[Ruby on Rails] Debug (binding.pry)
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
Ruby on Rails config configuration
Ruby on Rails basic learning ①
Ruby on rails learning record-2020.10.07 ②
Ruby on rails learning record-2020.10.07 ①
Ruby on rails learning record -2020.10.06
Ruby on Rails validation summary
Ruby on Rails Basic Memorandum
[Ruby On Rails] Description that allows only specific users to transition to the edit page
[Ruby on Rails] Only the user who posted can edit
I tried installing Ruby on Rails related plugin with vim-plug
[Ruby on Rails] Add a column with a foreign key constraint
(Ruby on Rails6) Display of the database that got the id of the database
[Environment construction] Get the Ruby on Rails 6 development environment within 1 hour
A note about the seed function of Ruby on Rails
[Ruby on Rails] Automatically enter the address from the zip code
[Ruby on Rails] Implement login function by add_token_to_users with API
[Apple login] Sign in with Apple implementation procedure (Ruby on Rails)
[Note] About the Fizz_Buzz problem (How Ruby on Rails works)
Install Ruby on MSYS2 with pacman
Ruby on Rails Overview (Beginner Summary)
[Ruby on Rails] Read try (: [],: key)
[Ruby on Rails] yarn install --check-files
Ruby on Rails variable, constant summary
Installing Ruby + Rails on Ubuntu 18.04 (rbenv)