Skip to content

Instantly share code, notes, and snippets.

@atomical
Last active December 19, 2015 04:59
Show Gist options
  • Select an option

  • Save atomical/5901432 to your computer and use it in GitHub Desktop.

Select an option

Save atomical/5901432 to your computer and use it in GitHub Desktop.

Revisions

  1. atomical revised this gist Jul 1, 2013. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,8 @@ def active_for_controller controller_name

    def active_for_action action_name
    params[:action].to_s == action_name.to_s ? 'active' : ''
    end
    end

    Usage:

    = link_to 'Some resource', resource_path, class: active_for_controller('resource')
  2. atomical renamed this gist Jul 1, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. atomical created this gist Jul 1, 2013.
    7 changes: 7 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    def active_for_controller controller_name
    params[:controller].to_s == controller_name.to_s ? 'active' : ''
    end

    def active_for_action action_name
    params[:action].to_s == action_name.to_s ? 'active' : ''
    end