Skip to content

Instantly share code, notes, and snippets.

@matenia
matenia / gist:4247582
Created December 10, 2012 00:00
two forms on one page (slim, not haml)
div class="span12"
table class="table table-hover"
- @list.products.each_with_index do |product, index|
- if !product.id.nil?
tr
td class="span1"
= #TOP FORM
= form_tag(votes_vote_up_path)
= submit_tag "UP"
- if current_user
@matenia
matenia / gist:2758056
Created May 20, 2012 13:08 — forked from jdkealy/gist:1323514
rails_admin ckeditor implementation
config.model PagePart do
configure :content do
ckeditor true
end
end
@matenia
matenia / bootstrap_topbar_list.rb
Created March 2, 2012 14:49 — forked from tmaier/bootstrap_topbar_list.rb
BootstrapTopbarList for simple-navigation and Twitter Bootstrap integration
# Renders an ItemContainer as a <ul> element and its containing items as <li> elements.
# Prepared to use inside the topbar of Twitter Bootstrap http://twitter.github.com/bootstrap/#navigation
#
# Register the renderer and use following code in your view:
# render_navigation(level: 1..2, renderer: :bootstrap_topbar_list, expand_all: true)
class BootstrapTopbarList < SimpleNavigation::Renderer::Base
def render(item_container)
if options[:is_subnavigation]
ul_class = "dropdown-menu"
@matenia
matenia / awesome_nested_set_optimization_helper.rb
Created September 5, 2010 01:25 — forked from lancejpollard/awesome_nested_set_optimization_helper.rb
Converts awesome_nested_set model into a flat array (one sql query!)
def simple_nested_set(clazz) # Post for example
stack = [] # Post for example
result = []
clazz.all(:order => "lft").each do |node|
if stack.empty?
stack.push({:node => node, :children => []})
result << stack.last
next
end
if stack.last[:node].lft < node.lft && node.lft < stack.last[:node].rgt