This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 31st, 2012  |  syntax: None  |  size: 0.50 KB  |  views: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # This is obviously one of your helper files
  2.  
  3. YourApp.helpers do
  4.   # see lib/current_controller_and_action.rb for more on why this works
  5.   # (and also why this is kind of a kludge)
  6.   def current_controller_and_action
  7.     @current_controller_and_action ||= begin
  8.       act, clr = @_template.to_s.sub(%r!^/!, "").split("/").reverse
  9.       clr ||= "app"
  10.       [clr, act]
  11.     end
  12.   end
  13.  
  14.   def current_controller; current_controller_and_action[0]; end
  15.   def current_action;     current_controller_and_action[1]; end
  16. end
clone this paste RAW Paste Data