Class: DcPiece

Inherits:
Object
  • Object
show all
Includes:
DcPieceConcern
Defined in:
app/models/dc_piece.rb

Overview

Schema information

Collection name: dc_piece : Pieces of content

_id                  BSON::ObjectId       _id
created_at           Time                 created_at
updated_at           Time                 Last updated at
name                 String               Unique name for piece
description          String               Short description of piece
picture              String               Picture contents of piece
thumbnail            String               Small version of picture if available
body                 String               Content of this piece
css                  String               CSS
script               String               Script, if script is included in piece
script_type          String               Script type
params               String               params
piece_id             BSON::ObjectId       Piece
div_id               String               Div (position name) id on design where this piece is rendered
site_id              BSON::ObjectId       Site name where this piece will belong to
order                Integer              Order to be used when pieces are positioned in the same div (location)
active               Mongoid::Boolean     Piece is active
valid_from           DateTime             Piece is valid from
valid_to             DateTime             Piece is valid to
created_by           BSON::ObjectId       created_by
updated_by           BSON::ObjectId       Last updated by

DcPiece collection is used for documents or pieces of web site which are common to site or perhaps to all sites in database. For example page footer is a good candidate to be saved in a dc_piece collection.

Documents in dc_pieces collection must have unique name assigned. Default DcPartRenderer also looks into dc_pieces collection and collects all documents which belong to current site (site_id field) and renders them according to div_id field value.

Class Method Summary collapse

Class Method Details

.choices4_piecesObject

Return choices for select for selecting documents on dc_part form.



70
71
72
# File 'app/models/dc_piece.rb', line 70

def self.choices4_pieces
  all.inject([]) { |r,piece| r << [ piece.name, piece._id] }
end