This project is archived and is in readonly mode.

#3706 ✓resolved
Josh Nichols

uninformative error message when using 'markdown' helper without bluecloth gem

Reported by Josh Nichols | January 16th, 2010 @ 05:38 AM

If you happen to use the markdown helper, like so:

<%= markdown(post.body) %>

You get a pretty uninformative error message:

ActionView::Template::Error (uninitialized constant ActionView::Helpers::TextHelper::BlueCloth) on line #4 of /Users/technicalpickles/code/scratch/rails-3-blog/app/views/posts/_post.html.erb:
1: <h2><%= link_to post, post %></h2>
2: 
3: <div id="<%= dom_id(post) %>" class="<%= dom_class(post) %>">
4:   <div class="body"><%= markdown(post.body) %></div>
5: 
6:   <ul class="actions">
7:     <li><%= 'Not' unless post.published? %> Published</li>

    app/views/posts/_post.html.erb:4:in `_render_template_887285710_17704920_230336'
    app/views/posts/show.html.erb:1:in `_render_template__976704918_17747910_0'
    app/controllers/posts_controller.rb:18:in `show'

Fortunately, I'm familiar enough with markdown and bluecloth to know it needs the bluecloth gem, so I'd add this to Gemfile:

gem 'bluecloth'

This doesn't really fix the problem. I double checked that BlueCloth is defined by bluecloth.rb, and it is.

The only way I was able to get it to work was:

<% require 'bluecloth' %>
<%= markdown(post.body) %>

I would have guessed this would have happened by adding it to Gemfile, or at latest, inside the markdown helper.

Comments and changes to this ticket

  • Josh Nichols

    Josh Nichols January 16th, 2010 @ 05:38 AM

    • Tag changed from action_view, markdown, rails3 to action_view, bugmash, markdown, rails3
  • Ravil Bayramgalin

    Ravil Bayramgalin January 16th, 2010 @ 08:24 AM

    Specifying gems in Gemfile doesn't require them automatically. You always need to require them manually, i prefer to do it in initializer.

  • Josh Nichols

    Josh Nichols January 16th, 2010 @ 04:38 PM

    That matches the behavior I'm seeing, but contradicts bundler's documentation:

    # Don't auto-require this gem.
    gem "rspec-rails", "1.2.9", :require_as => nil
    
    # Require something other than the default.
    gem "yajl-ruby", "0.6.7", :require_as => "yajl/json_gem"
    

    I did try specifically using @:require_as@, but that didn't work either.

  • Prem Sichanugrist (sikachu)

    Prem Sichanugrist (sikachu) February 11th, 2010 @ 03:46 PM

    • State changed from “new” to “resolved”

    Current master and 3.0.0.beta does automatically require those gems now. I think this can be closed :)

  • Rolando Murillo

    Rolando Murillo June 29th, 2010 @ 08:00 AM

    I've got the same problem. But I noted that I just need to restart the app to apply the changes within Gemfile.

  • Rolando Murillo

    Rolando Murillo June 29th, 2010 @ 08:00 AM

    I've got the same problem. But I noted that I just need to restart the app to apply the changes within Gemfile.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages