Skip to content

Instantly share code, notes, and snippets.

@amardaxini
amardaxini / README.markdown
Created August 16, 2011 07:27 — forked from ariera/README.markdown
Nestable, sortable and dragable categories

Nestable, sortable and dragable categories:

In the project I'm working on we wanted to have a Category model which we wanted to be nestable. But we also liked the user to have a draggable interface to manage and rearrange the order of his categories. So we chose awesome_nested_set for the model and jQuery.nestedSortable for the UI.

It took me some time to arrange things to work properly so I wanted to share my work in case it helps anybody.

Before beginning

you might want to take a look at a demo app

  1. go to: http://awesomenestedsortable.heroku.com/groups/
  2. click in show of any group
@amardaxini
amardaxini / activesupportconcern.rb
Created May 4, 2011 07:07
Active support concern handling
# Test1
module M
def foo
puts "M"
end
end
module N
include M
def foo
@amardaxini
amardaxini / thumbnail.rb
Created February 2, 2011 14:50
resize image using gd2 or generate thumbnail of image
require 'rubygems'
require 'gd2-ffij'
class Thumbnail
include GD2
def self.thumb(file_name,thumb_name,resized_width=100,resized_height=100,options={})
#import image
image = Image.import(file_name)
#resize image by passing width and height
resize_image = image.resize(resized_width, resized_height,true)
# export an image to desired file format