# Rendering text with textilize

**URL:** <https://www.ruby-forum.com/t/rendering-text-with-textilize/49373>\
**Category:** Rails\
**Created:** [December 3, 2005, 12:08am UTC](https://www.ruby-forum.com/t/rendering-text-with-textilize/49373 "2005-12-03T00:08:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![morykon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bb73d2/32.png) [@morykon](https://www.ruby-forum.com/u/morykon)\
**Post date:** [December 3, 2005, 12:08am UTC](https://www.ruby-forum.com/t/rendering-text-with-textilize/49373/1 "2005-12-03T00:08:13Z")

</div>

I’m building a site where the pages pull from a database so I can  
build a simple content management system for the client. The client  
will get a giant textarea to edit which then gets textilized on  
output.

So I tried this for the homepage, but textilize didn’t work (undefined  
method error). Is there a better way to accomplish what I want? I’d  
like to avoid using individual rhtml files for the pages since each  
page is simply database content.

def index  
render(:text=\> textilize(ContentAreas.find\_by\_name(“overview”).content),  
:layout=\>“content”)  
end

Thanks!

Brian

---

<div class="post-metadata">

**Author:** ![morykon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bb73d2/32.png) [@morykon](https://www.ruby-forum.com/u/morykon)\
**Post date:** [December 3, 2005, 12:28am UTC](https://www.ruby-forum.com/t/rendering-text-with-textilize/49373/2 "2005-12-03T00:28:27Z")

</div>

On 3-dec-2005, at 0:04, Brian Morykon wrote:

> def index  
> render(:text=\> textilize(ContentAreas.find\_by\_name  
> (“overview”).content),  
> :layout=\>“content”)  
> end

I don’t think textilize() is available as a method inside the  
controller context. You will need to hook it into  
your controller or directly call RedCloth (that would be the best in  
your case)

> 

def index  
render :text=\>RedCloth.new(ContentAreas.find\_by\_name  
(‘overview’).content).to\_html, :layout=\>‘content’  
end

–  
Julian ‘Julik’ Tarkhanov  
me at julik.nl

---

<div class="post-metadata">

**Author:** ![morykon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bb73d2/32.png) [@morykon](https://www.ruby-forum.com/u/morykon)\
**Post date:** [December 3, 2005, 12:28am UTC](https://www.ruby-forum.com/t/rendering-text-with-textilize/49373/3 "2005-12-03T00:28:27Z")

</div>

> def index  
> render :text=\>RedCloth.new(ContentAreas.find\_by\_name  
> (‘overview’).content).to\_html, :layout=\>‘content’  
> end

def index  
@content = ContentAreas.find\_by\_name(‘overview’).content  
render :inline =\> “\<%= textilize @content %\>”, :layout =\> ‘content’  
end

–  
rick  
[http://techno-weenie.net](http://techno-weenie.net)

---

<div class="post-metadata">

**Author:** ![morykon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bb73d2/32.png) [@morykon](https://www.ruby-forum.com/u/morykon)\
**Post date:** [December 3, 2005, 2:52pm UTC](https://www.ruby-forum.com/t/rendering-text-with-textilize/49373/4 "2005-12-03T14:52:24Z")

</div>

Julik and Rick,

I ended up going with Rick’s inline approach (although the other is  
good to know!). I had tried render :inline before but had the database  
call in the render line instead of broken out in a variable. Works  
perfect now.

Thank you both!
