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

Version Path
calculated_attributes-0.1.1 spec/support/models.rb
calculated_attributes-0.1.0 spec/support/models.rb
calculated_attributes-0.0.22 spec/support/models.rb
calculated_attributes-0.0.21 spec/support/models.rb
calculated_attributes-0.0.20 spec/support/models.rb
calculated_attributes-0.0.19 spec/support/models.rb
calculated_attributes-0.0.18 spec/support/models.rb
calculated_attributes-0.0.17 spec/support/models.rb
calculated_attributes-0.0.16 spec/support/models.rb
calculated_attributes-0.0.15 spec/support/models.rb