Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法从控制器检查当前页面?我试过
current_page?
但这会返回一个错误:
undefined method 'current_page?'
在控制器操作和视图中,可以使用以下帮助程序:
controller_name action_name
你可以从它的名字中猜出它们各自的作用。
尝试在视图中检查这样
logger.info("--------#{params[:controller]}-------------") logger.info("--------#{params[:action]}-------------")
见终端日志