ruby on rails - Arel returning count column as string instead of int -


i have 3 models: video, tag, , tagging. tags have many videos through taggings.

i have added scope tag includes video count each tag attribute on returned records:

class tag   def self.include_video_count     t = tag.arel_table     v = video.arel_table     joins(:videos).select([t[arel.star], v[:id].count.as("video_count")]).group(t[:id])   end end  tag.include_video_count.first.video_count # => "42" 

the problem count attribute being returned string instead of integer.

is there arel method missing specifies type value should returned as?

apparently depends on type of column database returns (which makes sense!)

postgres example returns count string.

https://github.com/rails/rails/issues/3647

so... basically.. you're outa luck (as ;)


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -