ruby rails dynamo db教程

时间:2013-05-21 23:44:55

标签: ruby-on-rails-3 amazon-dynamodb

我正在尝试开发一个使用AWS的dynamoDB作为数据库的应用程序。我在动力宝石的最后两天一直在尝试,但我正准备将电脑扔到窗外。

http://blog.megam.co/archives/201

https://github.com/aws/aws-sdk-ruby

https://github.com/Veraticus/Dynamoid

有人知道有关于那里的教程吗?

我开了一个新的rails应用程序

rails new newApp -O

添加到Gemfile:

gem 'execjs'
gem 'therubyracer'
gem 'aws-sdk'
gem 'dynamoid'
然后我做了

bundle install

在此之后我创建了两个初始化: dynamoid.rb:

    Dynamoid.configure do |config|
      config.adapter = 'aws_sdk' # This adapter establishes a connection to the DynamoDB servers using Amazon's own AWS gem.
      config.namespace = "dev" # To namespace tables created by Dynamoid from other tables you might have.
      config.warn_on_scan = true # Output a warning to the logger when you perform a scan rather than a query on a table.
      config.partitioning = true # Spread writes randomly across the database. See "partitioning" below for more.
      config.partition_size = false#200  # Determine the key space size that writes are randomly spread across.
      config.read_capacity = 1 # Read capacity for your tables
      config.write_capacity = 1 # Write capacity for your tables
    end

和aws-sdk.rb:

    require "aws"
    AWS.config({
      :access_key_id => '##########',
      :secret_access_key => '#############################',
    })                       

当我做的时候

rails s

它只是不加载localhost

1 个答案:

答案 0 :(得分:0)

DynamoDB gem有一个Rails 4的错误。

  1. 当您输入 rails s 时,发布您获得的错误。
  2. 您使用的是Rails 4还是Rails 3?
  3. 我们的Rails项目使用dynamoid https://github.com/indykish/nilavu和fake_dynamo。

    我们不使用aws-sdk.rb,但它适用于aws.yml

    development:
    
    bucket: megam
    use_ssl: false
    access_key_id: <acess_key>
    secret_access_key: <secret> 
    #dynamo_db_endpoint: localhost
    #dynamo_db_port: 4567
    #dynamo_db_endpoint: dynamodb.ap-southeast-1.amazonaws.com # Set the regional endpoint