Home > acts_as_dimensioned_gallery

acts_as_dimensioned_gallery

Acts_as_dimensioned_gallery is a project mainly written in Ruby, based on the MIT license.

Ruby on Rails image gallery plugin with flexible image dimension management

ActsAsDimensionedGallery

NEW! Updated for Rails 3! No longer works in Rails 2.x.

ActsAsDimensionedGallery is a Ruby on Rails plugin allowing developers to add an image gallery to any model in an existing project. The plugin allows image dimensions to be created, edited, or destroyed at any time and will retroactively apply all dimensions to previously uploaded images as well as all new images. Dimensions can be managed as gallery-specific or independently and existing dimensions can be added to any gallery.

!!!WARNING!!! ActsAsDimensionedGallery currently has very basic views and has not been extensively tested. Use with caution.

Usage

Follow these steps to install and configure the plugin:

  1. Run the dimensioned_gallery migration to create the needed database tables.

rake db:migrate:dimensioned_gallery

  1. In all models you want to add galleries to, call 'acts_as_dimensioned_gallery'. a) When creating links in pages rendered by controllers in the plugin app, the default behavior is to create polymorphic routes. To disable this, include ":automatic_polymorphic_routes => :false" after acts_as_dimensioned_gallery.

  2. Run 'rake dimensioned_gallery:initialize' to create the necessary directories.

  3. If you have not already, install the Image Magick application ( http://www.imagemagick.org/ ). In config/environment.rb, add 'IMAGE_MAGICK_PATH = "/path/to/image/magick"' (the path will usually be '/usr/bin' on Linux or something like 'C:\Program Files\ImageMagick' on Windows).

  4. If you would like to require a user to sign in before using the administrative functions, define 'AADG_AUTHENTICATE' as the function you would like the plugin to call before allowing access to administrative functions.

  5. Add the following to the resources you would like to add galleries to in routes.rb: resources :myresource do resources :galleries do resources :images end

    namespace(:aadgadmin, :namespace => '') do resources :galleries do resources :dimensions do get :set_gallery_dimension, :on => :member end resources :images do get :set_gallery_dimension, :on => :member end end resources :dimensions do resources :galleries end end end

namespace :aadgadmin do resources :dimensions do resources :galleries end end

Example for resource "Item":

Item.rb

class Item < ActiveRecord::Base acts_as_dimensioned_gallery end

##############################

config/environment.rb

add:

IMAGE_MAGICK_PATH = "/usr/bin" AADG_AUTHENTICATE = :authenticate_user!

##############################

config/routes.rb

add:

resources :items do resources :galleries do resources :images end

namespace(:aadgadmin, :namespace => '') do resources :galleries do resources :dimensions do get :set_gallery_dimension, :on => :member end resources :images do get :set_gallery_image, :on => :member end end resources :dimensions do resources :galleries end end end

namespace :aadgadmin do resources :dimensions do resources :galleries end end

##############################

Copyright (c) 2010 Matthew R. Dale, released under the MIT license

Previous:proj111