ruby-datamapper

DataMapper - Single Table Inheritance

房东的猫 提交于 2019-12-22 11:33:21
问题 Could Some one please explain to me what is going on here? This is an example that I put together to show y'all whats up: class Person include DataMapper::Resource property :id, Serial property :type, Discriminator property :name, String property :age, Integer end class Male < Person end class Father < Male property :job, String end class Son < Male end class Female < Person end class Mother < Female property :favorite_song, String end class Daughter < Female end DataMapper.auto_upgrade! If I

DataMapper - Single Table Inheritance

☆樱花仙子☆ 提交于 2019-12-22 11:32:44
问题 Could Some one please explain to me what is going on here? This is an example that I put together to show y'all whats up: class Person include DataMapper::Resource property :id, Serial property :type, Discriminator property :name, String property :age, Integer end class Male < Person end class Father < Male property :job, String end class Son < Male end class Female < Person end class Mother < Female property :favorite_song, String end class Daughter < Female end DataMapper.auto_upgrade! If I

Ruby Datamapper count not working

落爺英雄遲暮 提交于 2019-12-13 14:25:36
问题 From irb when I do: Router.all(:email=>"blake@gmail.com") I get a list of all the routers associated with that email. But when I do: Router.count(:email=>"blake@gmail.com") I always get 0 I've also looked at this question: Ruby Datamapper .count always returns 0 but I still don't know why it isn't working. -- Update #1 -- Here is the output of the Router.all command. As you can see I get results back. 1.9.3-p362 :003 > Router.all(:email=>"blake@gmail.com") => [#<Router @id=8 @email="blake

Sinatra: NameError at '/route', undefined local variable or method

旧街凉风 提交于 2019-12-12 02:21:45
问题 I'm trying to build an admin backend for a cms website. this is the structure of my application ├── app.rb ├── Gemfile ├── models │ └── models.rb ├── routes │ └── routes.rb └── views ├── categories.erb ├── # ... other view files app.rb require 'sinatra' require 'data_mapper' require 'dm-core' require 'dm-migrations' require 'digest' enable :sessions DataMapper.setup(:default, 'mysql://username:password@localhost/database') require './models/models.rb' require './routes/routes.rb' DataMapper

One-to-one DataMapper association

白昼怎懂夜的黑 提交于 2019-12-11 01:44:00
问题 I'm very new to DataMapper, and I'm trying to create models for the following scenario: I've got a number of users (with a user name, password etc.), who can also be players or referees or both (so Single Table Inheritance is not an option). The base models would be: class User include DataMapper::Resource property :id, Serial # Other user properties go here end class Player include DataMapper::Resource property :id, Serial # Other player properties go here # Some kind of association goes

ruby datamapper will not load

自古美人都是妖i 提交于 2019-12-09 12:11:45
问题 I was trying to learn about the Sinatra ruby framework by following this tutorial: http://net.tutsplus.com/tutorials/ruby/singing-with-sinatra-the-recall-app-2/ however, after running the gem install and writing a simple sinatra server in test.rb like so: require 'sinatra' require 'datamapper' get '/' do "Hello, World!" end but when I run the command ruby test.rb , I get the following error: /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -

DataMapper - Single Table Inheritance

≯℡__Kan透↙ 提交于 2019-12-06 05:21:11
Could Some one please explain to me what is going on here? This is an example that I put together to show y'all whats up: class Person include DataMapper::Resource property :id, Serial property :type, Discriminator property :name, String property :age, Integer end class Male < Person end class Father < Male property :job, String end class Son < Male end class Female < Person end class Mother < Female property :favorite_song, String end class Daughter < Female end DataMapper.auto_upgrade! If I call Person.all I get: Person.all => [#<Son @id=1 @type=Son @name="Mike" @age=23 @status=nil>, #<Son

gem install dm-postgres-adapter build error

笑着哭i 提交于 2019-12-04 11:27:24
问题 i'm trying to build dm-postgres-adapter but get this error. sudo gem install dm-postgres-adapter Building native extensions. This could take a while... ERROR: Error installing dm-postgres-adapter: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb checking for main() in -lpq... yes checking for libpq-fe.h... yes checking for libpq/libpq-fs.h... yes checking for postgres.h... yes checking for mb/pg_wchar.h... no ***

Is Datamapper's dm_mysql_adapter gem supported on windows?

拜拜、爱过 提交于 2019-12-04 02:19:39
问题 I am wanting to play some more with Ruby and currently seem to have a grasp of sinatra, but would also like to now pull in data from a relational database. I tend to use Mysql for test apps and tried installing the gems but I keep getting an exception when it tries to compile the native do_mysql gem which it is reliant upon. I do have the native extensions installed and they worked fine for the JSON gem, I remember reading somewhere a while back that the do_mysql wasnt supported for windows

ruby datamapper will not load

こ雲淡風輕ζ 提交于 2019-12-03 14:32:48
I was trying to learn about the Sinatra ruby framework by following this tutorial: http://net.tutsplus.com/tutorials/ruby/singing-with-sinatra-the-recall-app-2/ however, after running the gem install and writing a simple sinatra server in test.rb like so: require 'sinatra' require 'datamapper' get '/' do "Hello, World!" end but when I run the command ruby test.rb , I get the following error: /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- datamapper (LoadError) from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in