Sha256: 771c4fc908c28c36c8a0b459dbece21a8d0f12f492d21ed55072fa1f7f651b43
Contents?: true
Size: 562 Bytes
Versions: 10
Compression:
Stored size: 562 Bytes
Contents
class Post < ActiveRecord::Base calculated :comments, -> { 'select count(*) from comments where comments.post_id = posts.id' } calculated :comments_two, -> { 'select count(*) from comments where comments.post_id = posts.id' } calculated :comments_arel, -> { Comment.where(Comment.arel_table[:post_id].eq(Post.arel_table[:id])).select(Arel.sql('count(*)')) } end class Tutorial < Post end class Article < Post calculated :sub_comments, -> { 'select count(*) from comments where comments.post_id = posts.id' } end class Comment < ActiveRecord::Base end
Version data entries
10 entries across 10 versions & 1 rubygems