On Monday, April 4, 2011 9:52:04 PM UTC+3, rohit wrote:
>
> How about this? 
>
> ruby-1.8.7-p334 :001 > 
> DB[:checklists].select_append( DB[:marks].select{count(:*)}.filter( 
> :marks__checklist_id 
> => :checklists__id ).filter(:vote => 1).as(:votes_up) ) 
>  => #<Sequel::Dataset: "SELECT *, (SELECT count(*) FROM marks WHERE 
> ((marks.checklist_id = checklists.id) AND (vote = 1))) AS votes_up 
> FROM checklists">


Thanks!

One more question. If I try to serialize the result into a json, it gives me 
an error:

  NoMethodError: undefined method `votes_up' for #<Checklist:0x292ef508>

apparently because the dynamic column 'votes_up' wasn't predefined in 
'checklists' table. Is it possible somehow to provide such info to json 
serializer plugin?

-- 
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