Components, no so bad? Please help

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.

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

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


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

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. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs