JRuby – can’t convert Hash into String

I’ve recently upgraded a JRuby/Rails application from JRuby 1.6.3 (1.8 compatibility mode) to 1.6.8 (1.9 mode). Everything was working out fine except for actions relying on internal CSV library (FasterCSV in 1.8 mode). The error “ was thrown as CSV tries to generate the csv string. This had the hallmarks that the application was still under the 1.8 mode...

newrelic – undefined method `-’ for nil:NilClass

Using JRuby with trinidad (developer mode) – I was intermittently getting this error. Apparently thrown as estimated_time for the transaction was returning nil. I was also having all sorts of other issues (undefined method `metric_name’ for nil:NilClass) with all newrelics action summaries. To resolve (following suggestions on the trinidad google group): {% highlight ruby %} config/initializers/newrelic.rb if defined?(JRUBY_VERSION) &&...

JRuby/Rails Streaming in development environment (and beyond)

Rails streaming is a great feature that allows you to optimize on server resources when dealing with large generated content. However – it might be a bit tricky to validate and test in local development. First off – a local server that supports streaming is required. The only one I could find was trinidad which is moving to the...

JRuby and Polyglot

JRuby 1.5.6 (I know. Old) Rails 3.0.1 Polyglot 0.3.3 UPDATE: see easier fix below Getting the following error when bundling: {% highlight ruby %} Java::JavaLang::ArrayIndexOutOfBoundsException: An error occured while installing polyglot (0.3.3), and Bundler cannot continue. Make sure that gem install polyglot -v ‘0.3.3’ succeeds before bundling. {% endhighlight %} JRuby YAML parser is erring with this version of...

Rails, nested attributes and before_save callbacks

I had a Project model with a many ProjectWell (as in oil) association. Taking advantage of the accepts_nested_attributes, I was able to persist both Project and ProjectWell attributes through a single web form. {% highlight ruby %} class Project < ActiveRecord::Base has_many :project_wells accepts_nested_attributes_for :project_wells end class ProjectWell < ActiveRecord::Base belongs_to :project end {% endhighlight %} Now, the ProjectWell...

Test Oracle Database Views with Rails

Testing Rails with a legacy oracle schema as a backend is always a challenge (fun?). Rails relies no schema.rb to create its test database. The problem is that using the latest activerecord-oracle_enhanced-adapter (1.4.0), the application is unaware of the database views. So, I’ve decided to create those DB views (development) as DB tables (test). {% highlight ruby %} #names...

Rails – disable timezone conversions

In order to globally disable the use of TimeZone conversions for your (legacy?) application – here’s the proper configurations: In config/application.rb (or config/environment.rb depending on Rails version): 123 config.time_zone = ‘Mountain Time (US & Canada)’ #uncommented and set to proper zone config.active_record.default_timezone = :local config.active_record.time_zone_aware_attributes = false

Heroku timezone adjustment

Setting up timezone on Heroku instance using heroku gem (command line) {% highlight ruby %} heroku config:add TZ=America/Edmonton …. heroku console Time.now => … -0700 … {% endhighlight %} Heroku apparently accepts zoneinfo timezones. It works, thank you for the useful post. I set for Europe/London. Yeah thanks for this tip. Very handy. Awesome, this made my night much...

Contents Invalid public key / Fingerprint can’t be blank

Getting the above error message trying to deploy to Heroku (Windows, PuTTY keygen). Turns out the public/private key files saved through putty aren’t of a valid OpenSSH format (expected by Heroku). You can still use Putty Keygen by copying the text generated under “Public key for pasting into OpenSSH authorized_key file” (save it to your *.pub) I’m inching towards...