RailsCasts Pro episodes are now free!
Learn more or hide this
I wish CodeRay had a CoffeeScript scanner. That's really the only thing that tempts me to switch to Pygments.
Love these revised episodes. Would really like to see the episode on Cancan revised. :)
The information for implementing cancan hasn't really changed much for Rails 3. You can check out the wiki for cancan, which is what I recently used to get it up and running on my app: CanCan wiki
What's the difference in cache('somekey') do ... end and Rails.cache.fetch('somekey') do ... end? They seem fundamentally the same.
cache('somekey') do ... end
Rails.cache.fetch('somekey') do ... end
Invocation of pygments.rb class methods within a Rails 3.2 app just kills the entire server process. Anyone here has any experience of this?
This is happening to me. Very frustrating.
I tried the sample source code but it gives me this error. I hope you mentioned it in the notes or comments to other users to benefit.
Could not open library '/Library/Frameworks/Python.framework/Versions/2.7/lib/libPython2.7.dylib': dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/libPython2.7.dylib, 9): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/libPython2.7.dylib: no matching architecture in universal wrapper
Extracted source (around line #5):
4: <title>Code Highlighter</title>
5: <%= stylesheet_link_tag "application", media: "all" %>
7: <%= csrf_meta_tag %>
Application Trace | Framework Trace | Full Trace
And the solution is download and install the 64 bit version binary Python installer from Python.org website. Here is the direct download link
Got this up and running but seems to indent any code after line 1 by an extra four spaces. Anyone know if this is a pygments or Redcarpet issue or how to fix it?
Turns out this is a haml issue (http://stackoverflow.com/questions/6325416/maruku-incorrectly-parsing-second-line-of-code-blocks).
It can be fixed by adding 'preserve' i.e.
= preserve @foo
Awesome as usual. Seems like the caching would be a perfect fit for Redis. :-)
The redcarpet portion simply doesn't work for me. I can't get Pygments.highlight to work when called within redcarpet
I was also finding problems making Pigments work from within redcarpet. I finally opted for Coderay, as on the original version of this railscasts, here's what I did:
How to colorize code in comments using CodeRay
This helped me to build rack-markdown.
I downloaded and tried example, background doesn't work, how can I set background-color when I use the dark background theme? thanks.
Rouge is great gem for syntax highlighting and it's written in pure Ruby. I've written blog post with simple Rouge configuration with Redcarpet in Ruby on Rails.
Syntax highlighting in Ruby on Rails
I was able to get it working by following your blog post. I simplified the code a bit:
Syntax Highlighting using Rouge in Rails 4 Check it out: