databasedotcom-rails not supporting sobject_module?

Skip to first unread message

Mason Jones

Nov 22, 2011, 5:02:35 PM11/22/11
Hi, quick question primarily I guess for Danny. I'm trying out the
databasedotcom-rails gem, which seems quite nice. However, it's acting
as though it's not obeying the sobject_module specification in my
config. Here's what I've got:

databasedotcom.yml contains: sobject_module: SFDC_Models

In my controller:

class SfdcAccountsController < ApplicationController
include Databasedotcom::Rails::Controller

def index
@account = Account.find('theresanidhere')

That works. If I change the find to:

@account = SFDC_Models::Account.find('theresanidhere')

Then it doesn't work. I get the old "uninitialized constant
SFDC_Models::Account" error.

But when I try this in other code that doesn't use the
databasedotcom-rails gem, I can properly use the module specification.
Does this sound right, is it a known issue?


Mason Jones

Nov 22, 2011, 5:34:29 PM11/22/11
And to answer my own question, it looks like my guess was correct. I
had a few moments to take a look at the source for
databasedotcom-rails and the key is in controller.rb where
const_missing() uses sym.to_s to check if the symbol is in the
sobjects list. Doing sym.to_s on something like "SFDC_Models::Account"
won't find a match, of course.

I'm not sure what the best/safest way to handle this is. The "dumb"
way is to simply do a split on "::" and use the last piece of the
string, I guess, but I'll have to think about whether there are any
gotchas there. Anyone else have an idea?

Thx all.

Reply all
Reply to author
0 new messages