5

Something like Textile for the posts feels pretty necessary, but this is giving me all kinds of headaches. bundle package and bundle install are both working fine, and confirm that RedCloth is set to the latest stable release (4.2.2). Right now I'm on ruby 1.9.2p0 and rails 3.0.7.

When I try to run a local server, though, I'm seeing:

LoadError in PostsController#index

no such file to load -- RedCloth

...

app/controllers/posts_controller.rb:1:in `<top (required)>'

This error occurred while loading the following files:
   RedCloth

Line 1 in posts_controller is require 'RedCloth'. I haven't made any other changes to the basic Rails scaffold besides adding json formatting and a private authentication method, neither of which should be affecting this.

I'm using a partial to render my posts. It currently looks like this:

<% div_for post do %>
  <h2><%= link_to_unless_current h(post.title), post %> </h2>
  <%= RedCloth.new(post.body).to_html %>
<% end %>

Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.0.7'

gem 'sqlite3'
gem 'rake-compiler'
gem 'RedCloth'

group :development, :test do
  gem 'webrat'
  gem 'rspec'
  gem 'rspec-rails'
end

(rake-compiler is there from an attempt to follow these instructions, btw: http://www.ruby-forum.com/topic/484752 [I tried it with both ruby 1.9.1 and 1.9.2, no dice or else I wouldn't be here])

TIA :)

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239

2 Answers2

5

In your Gemfile, modify this line

gem 'RedCloth'

to

gem 'RedCloth', :require => 'redcloth'
Serabe
  • 3,834
  • 19
  • 24
0

Check gem installed like gem --list

Latest RedCloth version is 4.2.7 as i see in my gemset. Try the latest for concern.

You have absolutely no need to require any gem in your controllers as they are already required via bundle.

Try to test in rails console is RedCloth available.

sarvavijJana
  • 1,212
  • 10
  • 11
  • Yeah, i tried it at first with 4.2.7, with the same result. I went back to 4.2.2 because it's listed as the latest stable release. Not having the require line in the controller was also the first thing I tried. I got this error with it instead: NameError in Posts#index Showing /Users/dietcoupon/firelight/app/views/posts/_post.html.erb where line #3 raised: uninitialized constant ActionView::CompiledTemplates::RedCloth – Tracy Cogsdill Aug 30 '11 at 21:05
  • what s about rails console? could you access RedCloth? require it? – sarvavijJana Aug 30 '11 at 21:32
  • Ah! I'm getting `nil` for `require 'RedCloth'`. So, that means the Rails can't get at the RedCloth? How do I patch that up? – Tracy Cogsdill Aug 30 '11 at 21:48
  • Require error looks like `LoadError: no such file to load -- some_incredible_stuff_i_miss`. Try access RedCloth module from console & and you could also assure by finding your cloth in `$LOADED_FEATURES.find_all{|x| x=~/RedCl/}`. I think something is wrong with your RedCloth invocation in view. – sarvavijJana Aug 31 '11 at 07:11