Forum: Ruby on Rails Rendering text with textilize

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
morykon (Guest)
on 2005-12-03 01:08
(Received via mailing list)
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
listbox (Guest)
on 2005-12-03 01:28
(Received via mailing list)
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
technoweenie (Guest)
on 2005-12-03 01:28
(Received via mailing list)
> 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
morykon (Guest)
on 2005-12-03 15:52
(Received via mailing list)
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!
This topic is locked and can not be replied to.