Loading delegates in Rails View Helpers on to instance objects

33 views
Skip to first unread message

dcunited001

unread,
May 3, 2012, 1:31:40 AM5/3/12
to rubyonra...@googlegroups.com
Not sure if this should be done, but I'm writing some excel reports in ruby.  In the rxls views, i'm finding that i refer to @report all the time.  

In order to make my life easier i created a bunch of methods in the ReportsHelper for the base ReportsController.  But i'm finding that i'm essentially defining delegates that point straight to my @report object.  It makes my reports views more readable.

I wanted to find some way to load at least some of these methods as delegates.  I was thinking about using self.included on the ReportsHelper module and loading them onto the class there.  

I'm trying to look through ActionPack to see where these are loaded, but no dice.  I'm worried about any magic that might be going on.  Also, I'm just curious as to how and when these are loaded.  Any good places to start?

Piotr Sarnacki

unread,
May 3, 2012, 1:51:59 PM5/3/12
to rubyonra...@googlegroups.com
You could just do:

delegate :something, :to => "@report"

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/aULxrpmyo5IJ.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.



--
Piotr Sarnacki
http://piotrsarnacki.com
Reply all
Reply to author
Forward
0 new messages