Class: Forge::BannersController

Inherits:
ForgeController show all
Defined in:
lib/forge/app/controllers/forge/banners_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



21
22
23
24
25
26
27
28
29
# File 'lib/forge/app/controllers/forge/banners_controller.rb', line 21

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

#destroyObject



41
42
43
44
# File 'lib/forge/app/controllers/forge/banners_controller.rb', line 41

def destroy
  @banner.destroy
  redirect_to(forge_banners_path)
end

#editObject



18
19
# File 'lib/forge/app/controllers/forge/banners_controller.rb', line 18

def edit
end

#indexObject



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

def index
  respond_to do |format|
    format.html { @banners = Banner.order(:list_order).paginate(:per_page => 10, :page => params[:page]) }
    format.js {
      @banners = Banner.where("title LIKE ?", "%#{params[:q]}%")
      render :partial => "banner", :collection => @banners
    }
  end
end

#newObject



14
15
16
# File 'lib/forge/app/controllers/forge/banners_controller.rb', line 14

def new
  @banner = Banner.new
end

#reorderObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/forge/app/controllers/forge/banners_controller.rb', line 47

def reorder
  Banner.reorder!(params[:banner_list])

  respond_to do |format|
    format.js { render :nothing => true }
    format.html {
      flash[:notice] = "Banners reordered!"
      redirect_to :action => :index
    }
  end
end

#updateObject



31
32
33
34
35
36
37
38
39
# File 'lib/forge/app/controllers/forge/banners_controller.rb', line 31

def update
  @banner.photo = nil if params[:remove_asset] == "1"
  if @banner.update_attributes(params[:banner])
    flash[:notice] = 'Banner was successfully updated.'
    redirect_to(forge_banners_path)
  else
    render :action => "edit"
  end
end