RedCloth 破坏了我的 Rails 3 博客
像 Textile 这样的帖子感觉非常有必要,但这让我很头疼。 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:
RedCloth
posts_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 [我用 ruby 1.9.1 和 1.9.2 都尝试过,没有骰子,否则我不会在这里])
TIA :)
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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的 Gemfile 中,将此行修改
为
In your Gemfile, modify this line
to
检查已安装的 gem,如
gem --list
最新的 RedCloth 版本是 4.2.7,正如我在 gemset 中看到的那样。
尝试最新的关注。
您绝对不需要在控制器中添加任何 gem,因为它们已经通过捆绑包需要了。
尝试在 Rails 控制台中测试 RedCloth 是否可用。
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.