On Thu, Oct 13, 2011 at 21:33, Nokan Emiro <uzleep...@gmail.com> wrote: > How can I guess the view's name in my layout method? > > It would be great to know because of highlight the current > menu item the user has selected. Of course I can store it in > a variable in my controller just before I call render :view, but I > hope there's a much more sexy way to do this.
If you're using Markaby (that is, templates written in Ruby under MyApp::Views) and Ruby 1.9 you can use __method__: module App::Views def foo p "I'm inside: #{__method__}" end end But you can't use that in a layout or partial though (it would just return "layout" or the name of the partial)… _______________________________________________ Camping-list mailing list Camping-list@rubyforge.org http://rubyforge.org/mailman/listinfo/camping-list