alvincrespo
alvincrespo

Reputation: 9334

Uninitialized Constant in Rails 3.0.1 using the RedCloth 4.2.2 gem

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!

Upvotes: 3

Views: 3474

Answers (2)

Yura Omelchuk
Yura Omelchuk

Reputation: 391

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
...

Upvotes: 3

Dylan Markow
Dylan Markow

Reputation: 124439

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.

Upvotes: 4

Related Questions