Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Accessing rails render method outside of view / Decorating render

Thread Tools

Accessing rails render method outside of view / Decorating render

Glenn Gillen
Posts: n/a
I'm developing a plugin for rails that ultimately needs to assign some
HTML to a javascript variable. In the interest of DRY, I want to be
able to basically specify a partial and pass in a collection and then
render the results. Because I'm assigning the output to a variable
though I need to catch it and escape things like single quotes. The
two options I can immediately see are:

1) Create a method similar to render in my own class. This would do
the required operations on my object and then delegate the processing
to render in ActionView. My problem is, how do I actually call the
render method from within my own class?

2) Decorate the existing render method to recognise if my new object
type is passed in and react accordingly. My problem is, how do I do
that exactly? And in such away that if another developer wanted to do
the same thing it would then wrap both of our render methods and not
just overwrite the others?

Make sense? Any insight greatly appreciated


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
decorating a method in multiple child classes Python 0 07-17-2008 07:58 PM
ActiveRecord ids differ outside of rails for rails data table? Xeno Campanoli Ruby 1 06-03-2008 06:57 PM
help with pix inside->outside + dmz->outside + inside->outside->dmz Jack Cisco 0 09-19-2007 01:57 AM
Rails suggestions/examples on Rails view architecture for spreadsheet-liketables? Kenneth McDonald Ruby 0 04-26-2007 07:51 PM
Decorating div boxes with CSS Paul B HTML 10 04-14-2006 04:25 PM