# Render\_component alternatives

**URL:** <https://www.ruby-forum.com/t/render-component-alternatives/111006>\
**Category:** Rails\
**Created:** [August 1, 2007, 9:10pm UTC](https://www.ruby-forum.com/t/render-component-alternatives/111006 "2007-08-01T21:10:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghoti143](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/90db22/32.png) [@ghoti143](https://www.ruby-forum.com/u/ghoti143)\
**Post date:** [August 1, 2007, 9:10pm UTC](https://www.ruby-forum.com/t/render-component-alternatives/111006/1 "2007-08-01T21:10:14Z")

</div>

I am not sure if I am the only one, but I really like the idea of  
render\_component. Too bad it is depricated now. Currently I am using  
components so that I can have custom view functions with their own  
rhtml files in one folder. That way, I can and drop that folder into  
any of my projects and I have that component instantly available. Is  
there a better way of doing this?

# For example,

## foobar.rhtml

Hello \<%= @text %\> from foobar

## foo.rb

class FooController \< ActionController::Base  
def foo  
@text = params[:text]  
render :partial =\> “foobar”  
end  
end

def foo (text)  
render\_component :controller =\> “foo”, :action =\> “foo”, :params  
=\> {:text =\> text}  
end

## myapp.rhtml (using foo)

\<%= foo “hello” %\>

---

<div class="post-metadata">

**Author:** ![ghoti143](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/90db22/32.png) [@ghoti143](https://www.ruby-forum.com/u/ghoti143)\
**Post date:** [August 3, 2007, 4:42am UTC](https://www.ruby-forum.com/t/render-component-alternatives/111006/2 "2007-08-03T04:42:52Z")

</div>

how about a helper?

## app/views/shared/\_foobar.rhtml

Hello \<%= text %\> from foobar

## application\_helper.rb

def foo (text)  
render :partial =\> “/shared/foobar”, :locals =\> {:text =\> text}  
end

## myapp.rhtml (using foo)

\<%= foo “hello” %\>

Note that the partial expects ‘text’, not ‘@text’ sent via locals
