# Render\_component

**URL:** <https://www.ruby-forum.com/t/render-component/109321>\
**Category:** Rails\
**Created:** [July 13, 2007, 12:26pm UTC](https://www.ruby-forum.com/t/render-component/109321 "2007-07-13T12:26:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jotape](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jotape](https://www.ruby-forum.com/u/jotape)\
**Post date:** [July 13, 2007, 12:26pm UTC](https://www.ruby-forum.com/t/render-component/109321/1 "2007-07-13T12:26:19Z")

</div>

Hello all.

I have a view where I need to render an action.

If i do a render\_component in the view, my action code is not executed,  
and that’s bad for me…

My workaround is to do a render\_component\_as\_string in the first action  
and render this result along with my action rendering… and that’s  
pretty ugly ☹

Is there a way to do it another way?

---

<div class="post-metadata">

**Author:** ![jotape](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c77e96/32.png) [@jotape](https://www.ruby-forum.com/u/jotape)\
**Post date:** [July 13, 2007, 11:53pm UTC](https://www.ruby-forum.com/t/render-component/109321/2 "2007-07-13T23:53:38Z")

</div>

Pedro C. wrote:

> Hello all.
> 
> I have a view where I need to render an action.
> 
> If i do a render\_component in the view, my action code is not executed,  
> and that’s bad for me…
> 
> My workaround is to do a render\_component\_as\_string in the first action  
> and render this result along with my action rendering… and that’s  
> pretty ugly ☹
> 
> Is there a way to do it another way?

Put the action in the controller code?

If you are going to do this in a lot of places you could put the action  
as a method in application.rb and use a shared partial for its view.
