Matt
Matt

Reputation: 51

Why am I getting a NameError out of the box with rails SimpleRecord?

I installed the simple_record gem to use as an ActiveRecord replacement for my rails app. I followed the instructions from http://sites.appoxy.com/simple_record/ and setup an initializer to include the following:

SimpleRecord.establish_connection(AWS_CONFIG['access_key_id'], AWS_CONFIG['secret_access_key'])

When I fire up the rails server (rails s) with I get the following error:

.../.rvm/gems/ruby-1.9.3-p125/gems/simple_record-2.2.0/lib/simple_record/active_sdb.rb:121:in `establish_connection': uninitialized constant SimpleRecord::ActiveSdb::ActiveSdbConnect::Aws (NameError)

It seems that it is trying to find the class name "SimpleRecord::ActiveSdb::ActiveSdbConnect::Aws" but Aws doesn't existing within that namespace. SimpleRecord does require Aws, but it is separate from SimpleRecord. Why would rails be prepending Aws with the SimpleRecord::... namespace?

I'm fairly new to ruby and rails, so maybe my knowledge of name-spacing is lacking and this is an easy fix, but I've been searching for hours and I can't find any answers to my question.

Ruby version: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]

Rails version: Rails 3.2.1

SimpleRecord version: 2.2.0

Upvotes: 1

Views: 220

Answers (2)

Matt
Matt

Reputation: 51

I appreciate the help, but after a couple hours of testing things out, I realized that the issue was a conflict between the simple_record gem and the aws-sdk gem. I was trying to use both separately, but apparently that causes issues.

So, I disabled the aws-sdk gem and everything works as expected.

Upvotes: 2

Jackie Chan
Jackie Chan

Reputation: 2662

So reading the error message we can get the following, that in here:

active_sdb.rb:121
https://github.com/appoxy/simple_record/blob/master/lib/simple_record/active_sdb.rb#L121

the following method requires aws_access_key_id, aws_secret_access_key and some other params

def establish_connection(aws_access_key_id=nil, aws_secret_access_key=nil, params={})
        @connection = Aws::SdbInterface.new(aws_access_key_id, aws_secret_access_key, params)
end

So I suspect that Amazon web services access key/secret access key haven't been set up yet or were set up wrongly.

You might want to dig into the code deeper and see where the method was called and what else may cause the problem

Upvotes: 0

Related Questions