Class: Blog
- Inherits:
-
Object
- Object
- Blog
- Includes:
- ContentItem
- Defined in:
- app/models/blog.rb
Overview
A Blog is a collection of Postings which may or may not references a ‘ContentItem’ (eg Page). When a Blog references a Page, the Page sould be seen as the ‘Intro’ to this blog.
Instance Method Summary (collapse)
-
- (Object) create_posting(form_params, current_user)
Create a posting with attachments from params for current_user.
-
- (Object) page_tokens=(tokens)
page_tokens are page::object_ids of the pages which should be displayed on the sidebar of this blog.
-
- (Boolean) public?
True if user_role is not defined or eql 0.
-
- (Criteria) scoped_pages(options = nil)
find pages with filter.
-
- (Criteria) scoped_postings(options = nil)
find postings with filter.
Methods included from ContentItem
included, #markdown, #normalized_tags_with_weight
Instance Method Details
- (Object) create_posting(form_params, current_user)
Create a posting with attachments from params for current_user
44 45 46 47 48 49 50 51 |
# File 'app/models/blog.rb', line 44 def create_posting(form_params,current_user) posting = self.postings.create(form_params) posting.user = current_user if posting.save && self.save posting..each(&:save) if posting. end posting end |
- (Object) page_tokens=(tokens)
page_tokens are page::object_ids of the pages which should be displayed on the sidebar of this blog.
37 38 39 40 41 |
# File 'app/models/blog.rb', line 37 def page_tokens=(tokens) @pages_before = self.pages.unscoped self.pages.nullify self.pages.push(Page.criteria.for_ids(tokens).all) end |
- (Boolean) public?
True if user_role is not defined or eql 0
71 72 73 |
# File 'app/models/blog.rb', line 71 def public? self.user_role == nil || self.user_role == 0 end |
- (Criteria) scoped_pages(options = nil)
find pages with filter
65 66 67 68 |
# File 'app/models/blog.rb', line 65 def scoped_pages(=nil) return self.pages unless self.pages.where( ) end |
- (Criteria) scoped_postings(options = nil)
find postings with filter
57 58 59 60 |
# File 'app/models/blog.rb', line 57 def scoped_postings(=nil) return self.postings unless self.postings.unscoped.where( ) end |