title: How can I use readability gem on Rails 3.0.x?
body: <p>I'm going to use readability gem on my rails 3 app. I can't use it as advised on the github page <a href="http://github.com/sspinc/readability" rel="nofollow">http://github.com/sspinc/readability</a> inside the app although it works fine on ruby console.</p>
  
  <p>On the ruby console:</p>
  
  <pre><code>&gt; require 'open-uri'
   =&gt; true 
  &gt; require 'readability'
   =&gt; true
  &gt; doc = Nokogiri::HTML(open('http://google.com'))
   =&gt; #&lt;Nokogiri::HTML::Document:0x81345324 name="document"
  &gt; doc.to_readable
   =&gt; #&lt;Nokogiri::XML::Element:0x813299a8 name="html" 
  # (expected result without any error)
  </code></pre>
  
  <p>On the rails console:</p>
  
  <pre><code>&gt; doc = Nokogiri::HTML(open('http://google.com'))
   =&gt; #&lt;Nokogiri::HTML::Document:0x81c2baec name="document"
  # (and so on.. expected result)
  &gt; readable = doc.to_readable
  SyntaxError: /Users/apraditya/.rvm/gems/ruby-1.8.7-p299/gems/readability-0.1.5/lib/readability/js/readability.js:2: syntax error, unexpected '='
      if(typeof console !== 'undefined') {
                           ^
  /Users/apraditya/.rvm/gems/ruby-1.8.7-p299/gems/readability-0.1.5/lib/readability/js/readability.js:2: syntax error, unexpected '{', expecting kTHEN or ':' or '\n' or ';'
  /Users/apraditya/.rvm/gems/ruby-1.8.7-p299/gems/readability-0.1.5/lib/readability/js/readability.js:5: syntax error, unexpected '}', expecting $end
          from /Users/apraditya/.rvm/gems/ruby-1.8.7-p299/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
          from /Users/apraditya/.rvm/gems/ruby-1.8.7-p299/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
          from /Users/apraditya/.rvm/gems/ruby-1.8.7-p299/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
          from /Users/apraditya/.rvm/gems/ruby-1.8.7-p299/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
          from /Users/apraditya/.rvm/gems/ruby-1.8.7-p299/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
          from /Users/apraditya/.rvm/gems/ruby-1.8.7-p299/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
          from /Users/apraditya/.rvm/gems/ruby-1.8.7-p299/gems/harmony-0.5.6/lib/harmony/page.rb:76:in `load'
  </code></pre>
  
  <p>I verified that it is not a javascript syntax error. Judging by the active support error, it failed loading the dependencies, I suspect that Rails has failed to load the required gems that readability use (like harmony, johnson and envjs) to handle javascript and DOM in Ruby.</p>
  
  <p>So my guess was may be somthing wrong in the Gemfile? Here's my current Gemfile:</p>
  
  <pre><code>source 'http://rubygems.org'
  
  gem 'rails', '3.0.3'
  gem 'devise', '~&gt; 1.1.5'
  gem 'haml', '3.0.24'
  gem 'simple_form'
  gem 'cancan'
  gem 'will_paginate', '~&gt; 3.0.beta'
  gem 'feedzirra', :require =&gt; [ 'feedzirra' ]
  gem 'loofah', '1.0.0.beta.1'
  gem 'compass', '~&gt; 0.10.4'
  gem 'meta_where', '~&gt; 0.9'
  gem 'populator'
  gem 'simple-navigation'
  gem 'readability'
  </code></pre>
  
  <p>I have tried adding :require option in readability to specify harmony, johnson and envjs; and reran 'bundle install' without any error, but I still have the same error.</p>
  
  <p>I have also checked the config/application.rb to require all the gems in the Gemfile. with this line</p>
  
  <pre><code>Bundler.require(:default, Rails.env) if defined?(Bundler)
  </code></pre>
  
  <p>So, back to the question, how can I use readability on Rails 3.0.x? Did I miss something? I'm on MacOS 10.6.5 if that matters.</p>
  
  <p>Thank you</p>