datamapper

DataMapper has n through Resource DELETE (Remove from association) not working

自古美人都是妖i 提交于 2020-01-01 14:24:38
问题 I'm have this two classes, class User include DataMapper::Resource property :id, Serial property :name, String has n :posts, :through => Resource end class Post include DataMapper::Resource property :id, Serial property :title, String property :body, Text has n :users, :through => Resource end So once I have a new post like: Post.new(:title => "Hello World", :body = "Hi there").save I'm having serious problems to add and remove from the association, like: User.first.posts << Post.first #why

Some uncertainty with implementing the 3 structure Model (Domain object, data mapper and service)

删除回忆录丶 提交于 2020-01-01 14:23:15
问题 As the heading suggests I am having some small problems while implementing the 3 structure Model (Domain object, data mapper and service). In the past when someone was registering on my site I would simply do $user->register($firstName, $lastName, $emailAddress, $username...); and that method would run in steps like this 1. Check if the form sent was valid. 2. Check if all the required fields were filled. 3. Check the if the lengths of strings were valid and the range of integers etc. 4.

Some uncertainty with implementing the 3 structure Model (Domain object, data mapper and service)

自古美人都是妖i 提交于 2020-01-01 14:22:15
问题 As the heading suggests I am having some small problems while implementing the 3 structure Model (Domain object, data mapper and service). In the past when someone was registering on my site I would simply do $user->register($firstName, $lastName, $emailAddress, $username...); and that method would run in steps like this 1. Check if the form sent was valid. 2. Check if all the required fields were filled. 3. Check the if the lengths of strings were valid and the range of integers etc. 4.

Datamapper: Sorting results through association

心已入冬 提交于 2020-01-01 09:17:13
问题 I'm working on a Rails 3.2 app that uses Datamapper as its ORM. I'm looking for a way to sort a result set by an attribute of the associated model. Specifically I have the following models: class Vehicle include DataMapper::Resource belongs_to :user end class User include DataMapper::Resource has n, :vehicles end Now I want to be able to query the vehicles and sort them by the name of the driver. I tried the following but neither seems to work with Datamapper: > Vehicle.all( :order => 'users

Spork and cache_classes problem with rspec, factory_girl and datamapper

邮差的信 提交于 2020-01-01 02:33:07
问题 I've got a problem with Spork test server. If I set config.cache_classes = false in config/environments/test.rb then specs start to rasie errors. Failure/Error: task = Factory(:something, :foo => @foo, :bar => @bar) DataMapper::ImmutableError: Immutable resource cannot be modified This is my spec_helper.rb: require 'spork' Spork.prefork do if ENV['CODE_COVERAGE'] == '1' require 'simplecov' SimpleCov.start 'rails' end ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config

Is Data Mapper a more modern trend than Active Record

拜拜、爱过 提交于 2019-12-31 20:54:58
问题 I've come across a couple of ORMs that recently announced they are planning to move their implementation from Active Record to Data Mapper. My knowledge of this subject is very limited. So a question for those who know better, is Data Mapper newer than Active Record? Was it around when the Active Record movement started? How do the two relate together? Lastly since I'm not a database person and know little about this subject, should I follow an ORM that's moving to the Data Mapper

Is Data Mapper a more modern trend than Active Record

做~自己de王妃 提交于 2019-12-31 20:51:06
问题 I've come across a couple of ORMs that recently announced they are planning to move their implementation from Active Record to Data Mapper. My knowledge of this subject is very limited. So a question for those who know better, is Data Mapper newer than Active Record? Was it around when the Active Record movement started? How do the two relate together? Lastly since I'm not a database person and know little about this subject, should I follow an ORM that's moving to the Data Mapper

Cannot load such file — do_sqlite3/2.0/do_sqlite3 on windows

扶醉桌前 提交于 2019-12-25 06:36:56
问题 As far as I can tell, I've installed everything correctly, however I still can't run my program. To be clear, this was written on linux, and I'm now trying to run it on a windows machine. I have the following gem list: *** LOCAL GEMS *** addressable (2.2.7, 2.2.6) akami (1.2.2) backports (3.6.0) bcrypt (3.1.7 x64-mingw32) bcrypt-ruby (3.1.5 x64-mingw32) bigdecimal (1.2.0) builder (3.2.2, 3.1.4) bundle (0.0.1) bundler (1.6.2) daemons (1.1.9) data_mapper (1.2.0) data_objects (0.10.14) dm

Testing Datamapper models with RSpec

China☆狼群 提交于 2019-12-25 05:29:13
问题 I'm testing a Sinatra application, which is using DataMapper, with RSpec. The following code: it "should update the item's title" do lambda do post "/hello/edit", :params => { :title => 'goodbye', :body => 'goodbye world' } end.should change(Snippet, :title).from('hello').to('goodbye') end Results in this error: title should have initially been "hello", but was #<DataMapper::Property::String @model=Snippet @name=:title> I can of course hack this by removing the lambda and only checking if:

Creating MySQL triggers using DataMapper

你说的曾经没有我的故事 提交于 2019-12-25 03:32:47
问题 I've been trying to search and figure this on my own, but no luck so far :( I'd like to create MySQL triggers using DataMapper (or any other Ruby db adapter). Is this possible? I'd really like to have the triggers become part of my code versioning (for documentation and maintenance). 回答1: Simply execute arbitrary SQL in your migrations migration 1, :create_people_table do up do execute 'CREATE TRIGGER ...' end down do execute 'DROP TRIGGER ...' end end Of course, it won't be terribly portable