On Tuesday, March 1, 2016 at 1:35:10 PM UTC-8, Happy wrote:
>
> Hi,
> lets consider this:
>
> ws=Log.where(:user_id=>user.id, week_number: wn).exclude(:dsum=>0).exclude
> (:day=>date).group_and_count(:user_id, :week_number).select_append{sum(
> dsum).as(dsum)}
>
> Is following code the only way how to get "dsum"?
> dsum=ws.to_hash.values[0][:dsum]
>
> Thank you for advice.
>

ws here is a dataset.  I'm not sure if you want a single row or all the 
rows.  For a single row:

 ws.first[:dsum]

For all the rows:

  ws.each do |w|
    w[:dsum]
  end

You need to use [:dsum] instead of .dsum.  This is expected as column 
accessors are only setup for actual columns.  If you want to use .dsum:

  class Log
    def_column_accessor :dsum
  end

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to