Class: Blogit::Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Blogit::Post
- Defined in:
- app/models/blogit/post.rb
Class Method Summary (collapse)
-
+ (Object) active_with_id(id)
Finds an active post with given id.
-
+ (Object) for_feed
The posts to be displayed for RSS and XML feeds/sitemaps.
Instance Method Summary (collapse)
-
- (Object) blogger
The blogger (User, Admin, etc.) who wrote this Post.
-
- (Object) blogger_display_name
The blogger who wrote this Post's display name.
-
- (Object) blogger_twitter_username
If there's a blogger and that blogger responds to :twitter_username, returns that.
-
- (Object) comments
The Comments written on this Post.
- - (Object) comments=(value)
-
- (Object) published_at
TODO: Get published at working properly!.
-
- (Object) short_body
The content of the Post to be shown in the RSS feed.
- - (Object) to_param
Class Method Details
+ (Object) active_with_id(id)
Finds an active post with given id
61 62 63 |
# File 'app/models/blogit/post.rb', line 61 def self.active_with_id(id) active.find(id) end |
+ (Object) for_feed
The posts to be displayed for RSS and XML feeds/sitemaps
51 52 53 |
# File 'app/models/blogit/post.rb', line 51 def self.for_feed active.order('created_at DESC') end |
Instance Method Details
- (Object) blogger
The blogger (User, Admin, etc.) who wrote this Post
30 |
# File 'app/models/blogit/post.rb', line 30 belongs_to :blogger, :polymorphic => true |
- (Object) blogger_display_name
The blogger who wrote this Post's display name
106 107 108 109 110 111 112 113 114 |
# File 'app/models/blogit/post.rb', line 106 def blogger_display_name return "" if blogger.blank? if blogger.respond_to?(Blogit.configuration.blogger_display_name_method) blogger.send(Blogit.configuration.blogger_display_name_method) else method_name = Blogit.configuration.blogger_display_name_method raise ConfigurationError, "#{blogger.class}##{method_name} is not defined" end end |
- (Object) blogger_twitter_username
If there's a blogger and that blogger responds to :twitter_username, returns that. Otherwise, returns nil
118 119 120 121 122 |
# File 'app/models/blogit/post.rb', line 118 def blogger_twitter_username if blogger and blogger.respond_to?(:twitter_username) blogger.twitter_username end end |
- (Object) comments
The Comments written on this Post
36 |
# File 'app/models/blogit/post.rb', line 36 has_many :comments, :class_name => "Blogit::Comment" |
- (Object) comments=(value)
95 96 97 98 |
# File 'app/models/blogit/post.rb', line 95 def comments=(value) check_comments_config super(value) end |
- (Object) published_at
TODO: Get published at working properly!
70 71 72 |
# File 'app/models/blogit/post.rb', line 70 def published_at created_at end |
- (Object) short_body
The content of the Post to be shown in the RSS feed.
82 83 84 85 86 87 88 |
# File 'app/models/blogit/post.rb', line 82 def short_body if Blogit.configuration.show_post_description description else body end end |
- (Object) to_param
74 75 76 |
# File 'app/models/blogit/post.rb', line 74 def to_param "#{id}-#{title.parameterize}" end |