像Textile for the posts这样的东西感觉很有必要,但这让我头疼不已。bundle package和bundle install都工作正常,并确认RedCloth设置为最新的稳定版本(4.2.2)。现在我使用的是ruby 1.9.2p0和rails 3.0.7。
但是,当我尝试运行本地服务器时,我看到:
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:
RedClothposts_controller中的第1行是require 'RedCloth'。除了添加json格式化和私有身份验证方法之外,我没有对基本的Rails脚手架做任何其他更改,这两个都不应该影响这一点。
我正在使用片段来呈现我的帖子。它目前看起来是这样的:
<% 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是因为尝试遵循这些说明而出现的,顺便说一下:http://www.ruby-forum.com/topic/484752我在Ruby1.9.1和1.9.2上都试过了,没有骰子,否则我就不会在这里了)
TIA :)
发布于 2011-08-31 07:22:07
在Gemfile中,修改此行
gem 'RedCloth'至
gem 'RedCloth', :require => 'redcloth'发布于 2011-08-31 04:59:31
检查像gem --list一样安装的gem
正如我在gemset中看到的,最新的RedCloth版本是4.2.7。请尝试最新版本以备关注。
你绝对不需要在你的控制器中需要任何gem,因为它们已经通过bundle被需要了。
尝试在rails控制台中测试RedCloth是否可用。
https://stackoverflow.com/questions/7249433
复制相似问题