Advertisement
Guest User

Untitled

a guest
Mar 31st, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement