Accessing rails render method outside of view / Decorating render

Discussion in 'Ruby' started by Glenn Gillen, Nov 17, 2006.

  1. Glenn Gillen

    Glenn Gillen Guest

    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

    --
    Glenn
     
    Glenn Gillen, Nov 17, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    224
  2. Parthiv Joshi
    Replies:
    1
    Views:
    688
    Samuel L Matzen
    Jul 6, 2004
  3. Kenneth McDonald
    Replies:
    0
    Views:
    143
    Kenneth McDonald
    Apr 26, 2007
  4. Xeno Campanoli
    Replies:
    1
    Views:
    133
    Xeno Campanoli
    Jun 3, 2008
  5. Dan Stromberg
    Replies:
    1
    Views:
    84
    Steven D'Aprano
    Jun 7, 2014
Loading...

Share This Page