# Components, no so bad? Please help

**URL:** <https://www.ruby-forum.com/t/components-no-so-bad-please-help/93037>\
**Category:** Rails\
**Created:** [April 26, 2007, 8:54pm UTC](https://www.ruby-forum.com/t/components-no-so-bad-please-help/93037 "2007-04-26T20:54:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [April 26, 2007, 8:54pm UTC](https://www.ruby-forum.com/t/components-no-so-bad-please-help/93037/1 "2007-04-26T20:54:08Z")

</div>

I understand rails very well and am not new to rails by any means. I’ve  
read numerous websites on rails components, etc.

Based on my research and experience the only fallacy with components is  
the performance issues. Am I wrong?

I found that rendering a component on my website slowed it down 5 times.  
I took a look at my logs and noticed all of my before\_filters running  
twice. You get a method called component\_request? in your controller.  
You are also allowed to pass parameters to components. That being said,  
I was able to cut out a lot of the before filters and just pass the  
variables I needed using params. That cut the 5 down to 1.5. Now  
performance is not an issue.

Am I missing something here?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [April 26, 2007, 9:41pm UTC](https://www.ruby-forum.com/t/components-no-so-bad-please-help/93037/2 "2007-04-26T21:41:27Z")

</div>

The main issue with components is that you effectively get a new  
controller request with each component - so with a page with 3  
components it’s kinda like 4 requests in 1. This obviously present a  
performance issue.

Saying that, the main reasons components have fallen out of favour is  
firstly, they weren’t extracted from a ‘real-life’ situation (unlike  
most other features) and secondly, you can achieve pretty much the  
same thing using before filters and helpers, but much more  
efficiently.

Having said that, I’ve no doubt someone is working on a plugin to  
support components in a nicer way.

Steve

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [April 26, 2007, 10:13pm UTC](https://www.ruby-forum.com/t/components-no-so-bad-please-help/93037/3 "2007-04-26T22:13:30Z")

</div>

> From what I’ve read on the subject it’s not simple about performance,  
> although that’s a big part of it. It seems to be more about the fact  
> that design patterns exist the render components unnecessary in most  
> situation and it’s about reducing complexity, by more refined coding  
> conventions.

I also understand that Rails 2.0 may eliminate components from the  
standard libraries, so as a new Rails developer I will choose to avoid  
them entirely and stick with the patterns being promoted by the Rails  
core team.

On Apr 26, 2:54 pm, Ben J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
