Class Block
In: app/models/block.rb
Parent: ActiveRecord::Base

Methods

Included Modules

ActionView::Helpers::UrlHelper ActionView::Helpers::TagHelper BlockHelper

Public Class methods

returns the description of the block, used when the user sees a list of blocks to choose one to include in the design.

Must be redefined in subclasses to match the description of each block type.

[Source]

    # File app/models/block.rb, line 20
20:   def self.description
21:     '(dummy)'
22:   end

Public Instance methods

Returns the content to be used for this block.

This method can return several types of objects:

  • String: if the string starts with http:// or https://, then it is assumed to be address of an IFRAME. Otherwise it‘s is used as regular HTML.
  • Hash: the hash is used to build an URL that is used as the address for a IFRAME.
  • Proc: the Proc is evaluated in the scope of BoxesHelper. The

block can then use render, link_to, etc.

The method can also return nil, which means "no content".

See BoxesHelper#extract_block_content for implementation details.

[Source]

    # File app/models/block.rb, line 36
36:   def content
37:     "This is block number %d" % self.id
38:   end

[Source]

    # File app/models/block.rb, line 62
62:   def css_class_name
63:     self.class.name.underscore.gsub('_', '-')
64:   end

[Source]

    # File app/models/block.rb, line 66
66:   def default_title
67:     ''
68:   end

Is this block editable? (Default to false)

[Source]

    # File app/models/block.rb, line 49
49:   def editable?
50:     true
51:   end

A footer to be appended to the end of the block. Returns nil.

Override in your subclasses. You can return the same types supported by content.

[Source]

    # File app/models/block.rb, line 44
44:   def footer
45:     nil
46:   end

must always return false, except on MainBlock clas.

[Source]

    # File app/models/block.rb, line 54
54:   def main?
55:     false
56:   end

[Source]

    # File app/models/block.rb, line 58
58:   def owner
59:     box ? box.owner : nil
60:   end

[Source]

    # File app/models/block.rb, line 70
70:   def title
71:     if self[:title].blank?
72:       self.default_title
73:     else
74:       self[:title]
75:     end
76:   end

[Validate]