Sha256: 8730c33145a3a0b6aea36f71f43bd9aa85026b16dccb1f3814f5f9baf15e0d28

Contents?: true

Size: 873 Bytes

Versions: 13

Compression:

Stored size: 873 Bytes

Contents

class Topic < ActiveRecord::Base
  has_many :replies, :dependent => :destroy, :order => 'replies.created_at DESC'
  belongs_to :author

  named_scope :mentions_activerecord, :conditions => ['topics.title LIKE ?', '%ActiveRecord%']
  
  named_scope :with_replies_starting_with, lambda { |text|
    { :conditions => "replies.content LIKE '#{text}%' ", :include  => :replies }
  }
  
  named_scope :mentions_activerecord_with_replies, includes(:replies).mentions_activerecord
  named_scope :by_title_with_replies, lambda {|title| includes(:replies).where('topics.title like ?', title) }
  
  named_scope :join_replies_by_string, joins('inner join replies on topics.id = replies.topic_id')
  named_scope :join_replies_by_string_and_author, join_replies_by_string.joins(:author)
  named_scope :join_replies_by_string_and_author_lambda, join_replies_by_string.joins(:author)
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fake_arel-0.9.9 spec/fixtures/topic.rb
fake_arel-0.9.8 spec/fixtures/topic.rb
fake_arel-0.9.7 spec/fixtures/topic.rb
fake_arel-0.9.6 spec/fixtures/topic.rb
fake_arel-0.9.6pre spec/fixtures/topic.rb
fake_arel-0.9.5 spec/fixtures/topic.rb
fake_arel-0.9.4 spec/fixtures/topic.rb
fake_arel-0.9.3 spec/fixtures/topic.rb
fake_arel-0.9.2 spec/fixtures/topic.rb
fake_arel-0.9.1 spec/fixtures/topic.rb
fake_arel-0.9 spec/fixtures/topic.rb
fake_arel-0.8.1 spec/fixtures/topic.rb
fake_arel-0.8 spec/fixtures/topic.rb