Dynamoid icon indicating copy to clipboard operation
Dynamoid copied to clipboard

adding any index results crash

Open maxbugaenko opened this issue 10 years ago • 3 comments

this class works fine.

class Article
  include Dynamoid::Document
  table :name => :articles, :key => :id, :read_capacity => 1, :write_capacity => 1
  field :id, :integer
  field :uri
  field :place, :integer
end

but whenever i add INDEX into Article i get error:

`const_defined?': wrong constant name Aws-sdk (NameError)
class Article
  include Dynamoid::Document
  table :name => :articles, :key => :id, :read_capacity => 1, :write_capacity => 1
  field :id, :integer
  field :uri
  field :place, :integer
  index :place
end

maxbugaenko avatar Nov 11 '14 14:11 maxbugaenko

When you configure Dynamoid, you need to set the adapter configuration option to 'aws_sdk' rather than the default 'aws-sdk' option, which is incorrect.

This pulls in the correct adapter for the ruby dynamo sdk. You get this error when you include an index because this exercises a piece of code that necessitates accessing dynamo. You should get this same error if you were to run Article.new even in the first example.

ngordon17 avatar Mar 20 '15 05:03 ngordon17

Where to set the configuration? Any sample code link?

hlms avatar Mar 20 '15 16:03 hlms

Just add this wherever you do the initialization for your site or in spec_helper.rb if you just want to run tests.

Dynamoid.configure do |config| config.adapter = 'aws_sdk' end

ngordon17 avatar Mar 20 '15 19:03 ngordon17