簡體   English   中英

在資源的所有路由上處於活動狀態

[英]Active on all the routes of a resource

我使用link_to_active gem根據當前url添加“active”類。 我的要求是,例如:

學生資源有:

/students
/students/new
/students/id
/students/id/edit

我對link_to_active的使用:是

<%= link_to "Students", students_path, class: "list-group-item", active_on: students_path%>

很明顯,students_path只與/學生一致,但如果我想在訪問上述后續鏈接時保持此鏈接活動,該怎么辦? 我怎么做?

你看看這個寶石https://github.com/comfy/active_link_to ,它可以在控制器級別上匹配。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM