I''m trying to use markdown to HTML-ify text before saving that text to a database. I want to do this to save on server load (basically converting text to markup only once, rather than each time the page is called). Unfortunately, every time I call markup from my controller, I get an "undefined method `markdown''" message. Can I call markdown from the controller, or can it only be called from views? If it can be called from the controller, how does one go about doing this? Thanks in advance, -- Nathan Wright http://www.brandalism.com
You might want to make sure you have the markdown (or redcloth) installed. In addition, I might add that storing the un-htmlified source is a good idea to allow editing of the pages. Lately, I''ve stopped using the database to cache redcloth''s output and I now use Rail''s caching. This might not be applicable to your situation, but it removes some db complexity and I recommend you give it a try. -- Nicholas Seckar aka. Ulysses
Nicholas, Thanks for the quick reply.> You might want to make sure you have the markdown (or redcloth) > installed.I have both redcloth and bluecloth installed (via gems) and have called markdown from the view page with no problem via <%= markdown(comment.comment) %> . Calling markdown the same way in the controller page (minus the <% tags, of course) causes the error I mentioned earlier.> In > addition, I might add that storing the un-htmlified source is a good > idea to > allow editing of the pages.Normally I''d agree with you, but this is a simple comments page, much like one found on a typical blog. Basically, once the person leaves their comment, their comment is there.> Lately, I''ve stopped using the database to cache redcloth''s output and I > now use Rail''s caching. This might not be applicable to your situation, > but it removes some db complexity and I recommend you give it a try.Do you have any links about this? It sounds interesting, and I''d love to shed some DB complexity. -- Nathan Wright http://www.brandalism.com
> Do you have any links about this? It sounds interesting, and I''d love to > shed some DB complexity.May I present: Rails Caching (http://rails.rubyonrails.com/classes/ActionController/Caching.html) -- rick http://techno-weenie.net
> May I present: Rails Caching > (http://rails.rubyonrails.com/classes/ActionController/Caching.html)Looks great, but I get an error when I try to use it. undefined method `caches_page'' for Establishment:Class I assume that you put the cache statement in the model, is that correct? class Establishment < ActiveRecord::Base caches_page :new has_many :estcomments, :order => ''created_on ASC'' has_many :estlocations end -- Nathan Wright http://www.brandalism.com
On Wed, 30 Mar 2005 14:25:10 -0700, Nathan Wright <nathan-t2/9jZt1M8BPjb27YXYYTQ@public.gmane.org> wrote:> > May I present: Rails Caching > > (http://rails.rubyonrails.com/classes/ActionController/Caching.html) > > Looks great, but I get an error when I try to use it. > > undefined method `caches_page'' for Establishment:Class > > I assume that you put the cache statement in the model, is that correct? > > class Establishment < ActiveRecord::Base > caches_page :new > has_many :estcomments, :order => ''created_on ASC'' > has_many :estlocations > end > > > -- > Nathan Wright > http://www.brandalism.com > _______________________________________________You might notice that the caching documentation page is located in the ''ActionController'' module''s section, implying that you use it from your controller :) The model has no idea about page caching; in fact, models should not know anything about specific pages at all. Dave -- Dave Goodlad dgoodlad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org or dave-eHfbeeWWzZOw5LPnMra/2Q@public.gmane.org http://david.goodlad.ca/
> You might notice that the caching documentation page is located in the > ''ActionController'' module''s section, implying that you use it from > your controller :) The model has no idea about page caching; in fact, > models should not know anything about specific pages at all. >What david said, and you are looking for fragment caches. -- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog