# Rendering objects

**URL:** <https://www.ruby-forum.com/t/rendering-objects/100843>\
**Category:** Rails\
**Created:** [February 4, 2006, 2:09am UTC](https://www.ruby-forum.com/t/rendering-objects/100843 "2006-02-04T02:09:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heino\_HSGehlsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/76d3ee/32.png) [@Heino\_HSGehlsen](https://www.ruby-forum.com/u/Heino_HSGehlsen)\
**Post date:** [February 4, 2006, 2:09am UTC](https://www.ruby-forum.com/t/rendering-objects/100843/1 "2006-02-04T02:09:19Z")

</div>

So, Ruby is OO all the way, but in Rails we can?t render an object?

Having retyped way too many calls to ActionViews render method with  
various options, I finally figured, why not make it possible to actually  
render customized objects, which could encapsulate the often messy code,  
that I often ended up writing partly in the controller and partly in the  
view - using instance variables, and typing ?if? way too often in the  
template.

What I ended up with were ?Ren(d)jects?, objects capable of being  
rendered.

I have already made a functional plugin using only 66 lines of actual  
code (well, actually only 28, but I thought a few basic helpers would be  
nice ;-), and I would really like some feedback?

Source and documentation is avalible at  
[http://www.heino.gehlsen.dk/software/ruby/rails/plugins/renjects/](http://www.heino.gehlsen.dk/software/ruby/rails/plugins/renjects/). The  
documentation includes a brief introduction to the concept of Rendjets -  
and of cause a few small examples, which show how to use them. To some,  
the examples will perhaps at first sight seem at bit too complex, but  
think code reuse and easier debugging!

Having tried using Ren(d)jects when generating sidebars based on  
multiple independent blocks, I already find encapsulating partial  
rendering pretty neat ? from now on such blocks have to be very complex  
before I?ll end up using components?

Kind regards,  
Heino H. Gehlsen

---

<div class="post-metadata">

**Author:** ![Heino\_HSGehlsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/76d3ee/32.png) [@Heino\_HSGehlsen](https://www.ruby-forum.com/u/Heino_HSGehlsen)\
**Post date:** [February 4, 2006, 6:15am UTC](https://www.ruby-forum.com/t/rendering-objects/100843/2 "2006-02-04T06:15:42Z")

</div>

Heino,  
I have been looking for something like this.

Will try out over the weekend and let you know.

Thanks  
Frank  
[http://railsruby.blogspot.com](http://railsruby.blogspot.com)
