Class: Forge::GalleriesController

Inherits:
ForgeController show all
Defined in:
lib/forge/app/controllers/forge/galleries_controller.rb

Instance Method Summary collapse

Methods inherited from ForgeController

#get_menu_items, #load_help, #set_crumbs, #set_title, #uses_ckeditor

Methods inherited from ApplicationController

#app_init

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
# File 'lib/forge/app/controllers/forge/galleries_controller.rb', line 23

def create
  @gallery = Gallery.new(params[:gallery])
  if @gallery.save
    flash[:notice] = 'Gallery was successfully created.'
    redirect_to(forge_galleries_path)
  else
    render :action => "new"
  end
end

#destroyObject



42
43
44
45
# File 'lib/forge/app/controllers/forge/galleries_controller.rb', line 42

def destroy
  @gallery.destroy
  redirect_to(forge_galleries_path)
end

#editObject



19
20
21
# File 'lib/forge/app/controllers/forge/galleries_controller.rb', line 19

def edit
  @gallery = Gallery.find_with_photos(params[:id])
end

#indexObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/forge/app/controllers/forge/galleries_controller.rb', line 4

def index
  respond_to do |format|
    format.html { @galleries = Gallery.paginate(:per_page => 10, :page => params[:page]) }
    format.js { 
      params[:q] ||= ''
      @galleries = Gallery.where("LOWER(title) LIKE ?", "%#{params[:q].downcase}%")
      render :partial => "gallery", :collection => @galleries
    }
  end
end

#newObject



15
16
17
# File 'lib/forge/app/controllers/forge/galleries_controller.rb', line 15

def new
  @gallery = Gallery.new
end

#reorderObject



48
49
50
51
52
53
54
# File 'lib/forge/app/controllers/forge/galleries_controller.rb', line 48

def reorder
  Gallery.reorder!(params[:gallery_list])
  respond_to do |format|
    format.js { render :nothing => true }
    format.html {flash[:notice] = "Re-ordered successfully" and redirect_to forge_galleries_path }
  end
end

#updateObject



33
34
35
36
37
38
39
40
# File 'lib/forge/app/controllers/forge/galleries_controller.rb', line 33

def update
  if @gallery.update_attributes(params[:gallery])
    flash[:notice] = 'Gallery was successfully updated.'
    redirect_to(edit_forge_gallery_path(@gallery))
  else
    render :action => "edit"
  end
end