ruby

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...

NoMethodError: undefined method `eq’ for nil:NilClass

JRuby 1.5.2 Rails 3.0 activerecord-jdbc-adapter 0.9.7 This issue arises when setting table name with a schema name prefix. For those in the know – this is a must-have if you’re connecting to oracle using a non-owner username (activerecord-jdbc-adapter). {% highlight ruby %} class Model < ActiveRecord::Base set_table_name ‘.<table>’ end` </table></ts_code> Now – tracking this down led to lib/arel/engines/sql/relations/table.rb `def...

JRuby / PaperClip

Hello fellow developer stuck with JRuby, Paperclip file size = 0 issue 🙂 Apparently the Paperclip workaround to report the proper file size doesn’t work with the current implementation of JRuby (Windows XP). This “might” work (not thoroughly tested): iostream.rb 1234567891011if defined? Tempfile class Tempfile def size if self.path File.size(self.path) else 0 end end endend The issue is reported...

Multiple has_many_polymorphs in one model

I’m trying to define multiple polymorphic relations (has_many_polymorphs plugin) from a single parent to same children. Note has many viewersNote has many editorsViewers could be either Users or GroupsEditors could be either Users or GroupsPermission is the association model with note_id, viewer_id, viewer_type, editor_id, editor_type fields Everything works out as expect as long as I have only one has_many_polymorphs...

Is it Microsoft?

This exchange happened today between me and a client while presenting the final release of an application: Me: So, let’s now log in to the system…Client: Actually, I wanted to ask about something. Is this written using Microsoft technologies?Me: No, it’s written on a different stack.Client: Shoot!Me: Why?Client: What technology is it written with?Me: It’s written in Ruby, connects...

has_many_polymorphs broken for Rails 2.1.x

The guys on has_many_polymorphs are doing a great job keeping the plugin up to date with edge Rails. This commit broke the plugin with Rails 2.1.x NameError: uninitialized constant ActiveRecord::Reflection::ClassMethods::ThroughReflection Just revert to the AssociationReflection instead of ThroughReflection logic and all should be fine. Tamer: I’m a bit of a noob, and getting this error while trying to install...