Last active
August 29, 2015 14:05
-
-
Save kawahiro311/d12b2761353da92b3324 to your computer and use it in GitHub Desktop.
Railsでナビゲーションの現在地をアクティブにする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul class="nav"> | |
<li class="<%= active_class_for('controller1') %>"><a href="#">Controller1</a></li> | |
<li class="<%= active_class_for('controller2') %>"><a href="#">Controller2</a></li> | |
<li class="<%= active_class_for('controller3') %>"><a href="#">Controller3</a></li> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def active_class_for controller_name | |
'active' if params[:controller] == controller_name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment