Class: Formol::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/formol/post.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#created_by_topicObject

Virtual attributes



7
8
9
# File 'app/models/formol/post.rb', line 7

def created_by_topic
  @created_by_topic
end

#quote_idObject

Virtual attributes



7
8
9
# File 'app/models/formol/post.rb', line 7

def quote_id
  @quote_id
end

#register_user_as_subscriber(force_recompute = false) ⇒ Object

Read accessor for ‘register_user_as_subscriber’



7
8
9
# File 'app/models/formol/post.rb', line 7

def register_user_as_subscriber
  @register_user_as_subscriber
end

Class Method Details

.last_fivesObject

scope to get last five posts with reverse ordering usefull to have a little history when replying to a topic



64
65
66
# File 'app/models/formol/post.rb', line 64

def last_fives
  order('formol_posts.id DESC').limit(5).includes(:user)
end

.ordered_for_listingObject

scope for ordering posts conveniently for listing views order by id (no order is random with mysql)



53
54
55
# File 'app/models/formol/post.rb', line 53

def ordered_for_listing
  order('formol_posts.id ASC')
end

.ready_for_listingObject

scope to get posts conveniently prepared for listing



58
59
60
# File 'app/models/formol/post.rb', line 58

def ready_for_listing
  ordered_for_listing.includes(:topic, { :user => :preference })
end