# What is the difference between render partial and component?

**URL:** <https://www.ruby-forum.com/t/what-is-the-difference-between-render-partial-and-component/55439>\
**Category:** Rails\
**Created:** [March 21, 2006, 2:06am UTC](https://www.ruby-forum.com/t/what-is-the-difference-between-render-partial-and-component/55439 "2006-03-21T02:06:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [March 21, 2006, 2:06am UTC](https://www.ruby-forum.com/t/what-is-the-difference-between-render-partial-and-component/55439/1 "2006-03-21T02:06:30Z")

</div>

What is the difference between the render(:partial =\> ‘article’) and  
render\_component?

---

<div class="post-metadata">

**Author:** ![guest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8dc957/32.png) [@guest](https://www.ruby-forum.com/u/guest)\
**Post date:** [March 21, 2006, 8:40am UTC](https://www.ruby-forum.com/t/what-is-the-difference-between-render-partial-and-component/55439/2 "2006-03-21T08:40:36Z")

</div>

On Mar 21, 2006, at 2:06, Guest wrote:

> What is the difference between the render(:partial =\> ‘article’) and  
> render\_component?

A partial is just a template, render :partial specifies you want to  
render a chunk of view, either from another template, or as view of  
some action that has no layout. A partial template has no  
corresponding action.

On the other hand render\_component means “invoke this action in this  
controller with this parameters and include its output here”.

As a rule of thumb, if there’s a reusable piece of template that oly  
renders stuff already known to the templates it belongs you factor  
that out as a partial. A partial may be suitable also for actions  
that only respond to Ajax calls, though there you only use the fact  
that there’s no layout. In that case my personal choice is a regular  
template with :layout =\> false.

Otherwise, if that piece of view needs some application logic, like a  
shopping cart summary in the main layout of a shop, it is cleaner to  
call the shopping cart controller from the layout and delegate the  
logic to build that part to the controller that knows about it.

If some piece of view is not reusable but is rendered both as part of  
a normal template and as an Ajax call that updates that piece later,  
I factor that out as render\_component when building the first non-  
Ajax response as well.

– fxn
