Skip to content

Instantly share code, notes, and snippets.

@rossnelson
Created January 23, 2012 19:38
Show Gist options
  • Save rossnelson/1665136 to your computer and use it in GitHub Desktop.
Save rossnelson/1665136 to your computer and use it in GitHub Desktop.
Block Region Setup
# 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
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
.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