ruby - DataMapper Error with Models(`fetch': key not found: :precision (KeyError)) -


really new programming , programming community, , second project programming ruby excuse me if i'm missing obvious or doing wrong.

in project far, i'm trying create database using datamapper. database should include 3 objects: user, category, , class. user can have many category, , category can belong many users, why linked these 2 objects usercategory create many-many relationship. association between category , class, category object can have many classes, class can belong 1 category. database far:

require "sinatra" require "data_mapper" if env['rack_env'] == 'production'   datamapper.setup(:default, env['database_url']) else   datamapper.setup(:default, "sqlite:online-arena.db") end  class user   include datamapper::resource    property :id,           serial    property :username,     string,     :required => true,     :unique   => true    property :password,     bcrypthash, :required => true   validates_confirmation_of :password      attr_accessor :password_confirmation     validates_length_of :password_confirmation, :min => 6      def valid_password?(unhashed_password)       self.password == unhashed_password     end    property :admin,       boolean, default: false      has n, :user_categories     has n, :categories, through: :user_categories end  class usercategory   include datamapper::resource    property :id,         serial    belongs_to    :user   belongs_to    :category end  class category   include datamapper::resource    property :id,           serial   property :title,         string    has n, :class    has n, :user_categories   has n, :users, through: :user_categories end   class class   include datamapper::resource    property :id,           serial   property :name,         string   property :teacher,      string   property :spots,        integer    belongs_to :category end   datamapper.finalize datamapper.auto_upgrade! 

these gems i'm using project:

source "https://rubygems.org"  gem "sinatra" gem "data_mapper" gem "bcrypt" gem "rake"  group :development   gem "sqlite3"   gem "dm-sqlite-adapter"    gem "dotenv"   gem "rerun" end  group :production   gem "pg"   gem "dm-postgres-adapter" end 

i'm using cloud9 work on project , far, have "bundle install --without production", , launched "ruby online-arena.rb -p $port -o $ip" it's giving me error:

/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/dm-core-1.2.1/lib/dm-core/property/numeric.rb:19:in `fetch': key not found: :precision (keyerror)     /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/dm-core-1.2.1/lib/dm-core/property/numeric.rb:19:in `initialize'     /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/dm-core-1.2.1/lib/dm-core/property/integer.rb:15:in `initialize'     /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/dm-core-1.2.1/lib/dm-core/model/property.rb:55:in `new'     /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/dm-core-1.2.1/lib/dm-core/model/property.rb:55:in `property'     /usr/local/rvm/gems/ruby-2.1.5@rails4/gems/dm-validations-1.2.0/lib/dm-validations/auto_validate.rb:11:in `property'     /home/ubuntu/workspace/models.rb:49:in `<class:class>'     /home/ubuntu/workspace/models.rb:46:in `<top (required)>'     /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require'     /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require'     /home/ubuntu/workspace/environment.rb:5:in `<top (required)>'     /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require'     /usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:121:in `require'     online-arena.rb:4:in `<main>' 

if there isn't enough information, here's rest of files on github https://github.com/furiouspenguins/online-arena


i tried using previous project's database model has similar layout:

https://github.com/kichoy/lunch-reviews/blob/master/models.rb

and able run application.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -