Ah, didn't fully ead the docs then.

Thanks!
François

Le 2011-06-21 à 19:37, Jeremy Evans <[email protected]> a écrit :

> On Jun 21, 1:40 pm, François Beausoleil
> <[email protected]> wrote:
>> Hi!
>> 
>> I have this:
>> 
>> class User < Sequel::Model(:users)
>>   one_to_many :contacts
>> end
>> 
>> class Contact < Sequel::Model(:contacts)
>> end
>> 
>> Calling User.first.contacts.filter(:name => /abc/) raises a
>> NoMethodError:
>> 
>> NoMethodError: undefined method `filter' for #<Array:0x00000103660c48>
>>         from (irb):4
>>         from /Users/francois/.rvm/gems/ruby-1.9.2-p180@meetphil/bundler/gems/
>> rails-391b3739864c/railties/lib/rails/commands/console.rb:45:in
>> `start'
>>         from /Users/francois/.rvm/gems/ruby-1.9.2-p180@meetphil/bundler/gems/
>> rails-391b3739864c/railties/lib/rails/commands/console.rb:8:in `start'
>>         from /Users/francois/.rvm/gems/ruby-1.9.2-p180@meetphil/bundler/gems/
>> rails-391b3739864c/railties/lib/rails/commands.rb:40:in `<top
>> (required)>'
>>         from script/rails:6:in `require'
>>         from script/rails:6:in `<main>'
>> 
>> There must be a good reason for associations to not return datasets.
>> Is there any way to get a dataset instead of a collection?
> 
> There is.  Eager loading can't work if model association methods
> return datasets (Sequel doesn't use proxies for associations).  Use
> contacts_dataset instead of contacts if you want a dataset.
> 
>> I'm working on a multi-tenant database, and I would really like to be
>> able to continue filtering after going through the current user for
>> the contacts available to them.
> 
> In addition to using contacts_dataset, you could also pass a block to
> contacts:
> 
>  User.first.contacts{|ds| ds.filter(:name => /abc/)}
> 
> Jeremy
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sequel-talk" 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/sequel-talk?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" 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/sequel-talk?hl=en.

Reply via email to