Created
January 23, 2012 19:38
-
-
Save rossnelson/1665136 to your computer and use it in GitHub Desktop.
Block Region Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build instance variables for block regions and loads an | |
# array of blocks into them | |
def load_blocks | |
@regions = Block.regions | |
@blocks = regions.blocks | |
@block_regions = regions.regions | |
@block_regions.each do |block, value| | |
instance_variable_set "@#{block}", @blocks.select{ |b| b if b.where_to_show == value } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.regions | |
regions = { | |
:blocks => self.all, | |
:regions => { | |
:header_blocks => "header", | |
:left_blocks => "left", | |
:content_blocks => "content", | |
:right_blocks => "right", | |
:footer_blocks => "footer", | |
} | |
} | |
Hashie::Mash.new(regions) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.item | |
%br/ | |
= f.select(:where_to_show, @block_regions.map{|k,v| [k.titleize,v]}, {:prompt => 'Where should I show up?'}, :class => 'field') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment