【问题标题】:RedCloth is breaking my Rails 3 blogRedCloth 正在破坏我的 Rails 3 博客
【发布时间】:2011-11-07 03:28:36
【问题描述】:

像 Textile 这样的帖子感觉非常必要,但这让我很头疼。 bundle packagebundle 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 %>

宝石文件:

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 :)

【问题讨论】:

    标签: ruby ruby-on-rails-3 rubygems redcloth


    【解决方案1】:

    检查已安装的 gem,如 gem --list

    我在 gemset 中看到的最新 RedCloth 版本是 4.2.7。 尝试最新的关注。

    你完全不需要在你的控制器中使用任何 gem,因为它们已经通过 bundle 被需要了。

    尝试在 Rails 控制台中测试 RedCloth 是否可用。

    【讨论】:

    • 是的,我一开始用 4.2.7 试过,结果一样。我回到 4.2.2,因为它被列为最新的稳定版本。在控制器中没有 require 行也是我尝试的第一件事。我得到了这个错误:Posts#index 中的 NameError Showing /Users/dietcoupon/firelight/app/views/posts/_post.html.erb where line #3 raise: uninitialized constant ActionView::CompiledTemplates::RedCloth
    • rails 控制台怎么样?你能访问 RedCloth 吗?需要吗?
    • 啊!我正在为require 'RedCloth' 收到nil。那么,这是否意味着 Rails 无法到达 RedCloth?我该如何修补它?
    • 要求错误类似于LoadError: no such file to load -- some_incredible_stuff_i_miss。尝试从控制台访问 RedCloth 模块,您也可以通过在 $LOADED_FEATURES.find_all{|x| x=~/RedCl/} 中找到您的布料来确保。我认为您的 RedCloth 调用有问题。
    【解决方案2】:

    在你的 Gemfile 中,修改这一行

    gem 'RedCloth'
    

    gem 'RedCloth', :require => 'redcloth'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-02
      • 2015-07-21
      • 1970-01-01
      • 2017-12-09
      • 1970-01-01
      • 2017-06-13
      • 2012-03-10
      相关资源
      最近更新 更多