I have not used the ldap adapter yet, but with two databases the code works. can please verify that this code http://gist.github.com/117398 works for you as well.
in the mean while I fix my ldap installation (got a bit mangled with the last OS upgrade) and see if I can reproduce the problem. with regards Kristian On May 23, 7:01 pm, fbettag <[email protected]> wrote: > class Customer > include DataMapper::Resource > > property :id, Serial, :field => "cn" > property :name, String, :field => "o" > property :unit, String, :field => "ou" > > has n, :positions > has n, :bills > dn_prefix { |customer| "cn=#{customer.id}"} > > treebase "ou=Customers" > > ldap_properties do |customer| > properties = { :objectclass => ["groupOfNames"] } > properties > end > > def self.auto_upgrade!(args = nil) > DataMapper.logger.warn("Skipping #{self.name}.auto_upgrade!") > end > > def self.default_repository_name > :ldap > end > > end > > class Position > include DataMapper::Resource > include DataMapper::Stamped > > property :id, Serial > property :name, String, :length => 100, :nullable => false > property :category, String, :length => 40, :nullable => false > property :text, Text, :nullable => false, :nullable => false > property :note, String, :length => 255 > > property :amount, BigDecimal, :nullable => false > property :price, BigDecimal, :nullable => false > > property :currency, String, :limit => 3..3, :nullable => > false, :default => 'EUR' > property :tax, BigDecimal, :nullable => false, :default => 19 > > property :paynow, String, :limit => 10 > property :outbound, Boolean, :nullable => false, :default => false > property :sorting, Integer > > belongs_to :customer > > # property :customer_id, Integer, :nullable => false > > def customer > return nil unless self.customer_id > DataMapper.repository(:ldap) do > Customer.get(self.customer_id) > end > end > > def customer=(c) > self.customer_id = c.id if c > end > > belongs_to :bill > > end > > irb(main):002:0> Customer.first.positions > ~ (0.000345) SET backslash_quote = off > ~ (0.000401) SET standard_conforming_strings = on > ~ (0.004327) SELECT "updated_at", "created_by_id", "created_at", > "updated_by_id", "deleted_by_id", "id", "name", "category", "note", > "amount", "price", "currency", "tax", "paynow", "outbound", "sorting", > "customer_id", "bill_id" FROM "positions" WHERE ("deleted_at" IS NULL) > AND ("customer_id" IN ('10010')) ORDER BY "id" > NoMethodError: undefined method `positions_association' for > nil:NilClass > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > associations/relationship.rb:106:in `send' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > associations/relationship.rb:106:in `get_children' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > associations/relationship.rb:105:in `each' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > associations/relationship.rb:105:in `get_children' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > associations/relationship.rb:172:in `with_repository' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > support/kernel.rb:6:in `repository' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm- > core.rb:181:in `repository' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > repository.rb:44:in `scope' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm- > core.rb:181:in `repository' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > support/kernel.rb:6:in `repository' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > associations/relationship.rb:172:in `with_repository' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > associations/relationship.rb:82:in `get_children' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > associations/one_to_many.rb:251:in `children' > from /usr/lib64/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/ > associations/one_to_many.rb:309:in `method_missing' > from /usr/lib64/ruby/1.8/irb.rb:302:in `output_value' > from /usr/lib64/ruby/1.8/irb.rb:151:in `eval_input' > from /usr/lib64/ruby/1.8/irb.rb:263:in `signal_status' > from /usr/lib64/ruby/1.8/irb.rb:147:in `eval_input' > from /usr/lib64/ruby/1.8/irb.rb:146:in `eval_input' > from /usr/lib64/ruby/1.8/irb.rb:70:in `start' > from /usr/lib64/ruby/1.8/irb.rb:69:in `catch' > from /usr/lib64/ruby/1.8/irb.rb:69:in `start' > from /usr/lib64/ruby/gems/1.8/gems/merb-core-1.0.11/lib/merb- > core/rack/adapter/irb.rb:161:in `start' > from /usr/lib64/ruby/gems/1.8/gems/merb-core-1.0.11/lib/merb- > core/server.rb:174:in `bootup' > from /usr/lib64/ruby/gems/1.8/gems/merb-core-1.0.11/lib/merb- > core/server.rb:42:in `start' > from /usr/lib64/ruby/gems/1.8/gems/merb-core-1.0.11/lib/merb- > core.rb:170:in `start' > from /usr/lib64/ruby/gems/1.8/gems/merb-core-1.0.11/bin/merb: > 11 > from /usr/bin/merb:19:in `load' > from /usr/bin/merb:19irb(main):003:0> > > And yes, the query above returns rows. > > Any ideas? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
