Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check current page from controller in Rails?

Is there a way to check the current page from the controller? I tried

current_page?

but that returns an error :

undefined method 'current_page?'
like image 212
Arif Avatar asked Dec 24 '22 03:12

Arif


2 Answers

In the controller action and view the following helpers are available:

controller_name
action_name

You can guess from its' names, what each does.

like image 160
Andrey Deineko Avatar answered Dec 28 '22 07:12

Andrey Deineko


try to check like this in view

logger.info("--------#{params[:controller]}-------------")

logger.info("--------#{params[:action]}-------------")

see in log of terminal

like image 26
Pooja Mokariya Avatar answered Dec 28 '22 06:12

Pooja Mokariya