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
On 3-dec-2005, at 0:04, Brian Morykon wrote:> 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") > endI 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
> def index > render :text=>RedCloth.new(ContentAreas.find_by_name > (''overview'').content).to_html, :layout=>''content'' > enddef index @content = ContentAreas.find_by_name(''overview'').content render :inline => "<%= textilize @content %>", :layout => ''content'' end -- rick http://techno-weenie.net
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! On 12/2/05, Rick Olson <technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >