3

I'm having an issue with using RedCloth in my local application. I keep getting the following error:

uninitialized constant ActionView::CompiledTemplates::RedCloth

This happens because I have the following code:

<%= RedCloth.new("Some text").to_html %>

What I tried to do is put this in the environment.rb file:

require "RedCloth"

However, when I do this, I get a huge error with my Phusion Passenger + Nginx configuration, which I've detailed in the following forum: http://railsforum.com/viewtopic.php?id=42560

Any help would be great. Thanks!

Darren
  • 68,902
  • 24
  • 138
  • 144
alvincrespo
  • 9,224
  • 13
  • 46
  • 60

2 Answers2

4

Make sure your Gemfile has a gem 'RedCloth' in it. Regardless of which gems are actually installed in your system, Rails will only use the gems listed in your Gemfile. You do not need the require "RedCloth" statement either.

Dylan Markow
  • 123,080
  • 26
  • 284
  • 201
  • wow...I can't believe that was my problem. Thanks for your help, hopefully no one else runs into this...now i feel like newb. – alvincrespo Jan 19 '11 at 18:12
  • 1
    +1 I ran into the same problem today. It's partially that I am a newb, and partially that there is nothing in the instructions that tell us to include that in the gemfile. :-/ – jyoseph Jan 28 '11 at 16:40
  • 1
    @jyoseph: Generally, you **always** need to have any gems you use listed in your `Gemfile` -- it's not just a RedCloth thing. – Dylan Markow Jan 28 '11 at 17:43
3

I had exactly the same error and gem 'RedCloth' line was present in Gemfile. What helped was adding require statement in the beginning of controller file

require 'redcloth'

class StaticController < ApplicationController
...
Yura Omelchuk
  • 391
  • 1
  • 5