Class: Admin::ImagesController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/images_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#access_denied

Methods included from BaseHelper

#render_subnav

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
# File 'app/controllers/admin/images_controller.rb', line 20

def create
  @image = Image.new(params[:image])
  if @image.save
    redirect_to admin_images_path
  else
    render :new
  end
end

#destroyObject



42
43
44
45
46
# File 'app/controllers/admin/images_controller.rb', line 42

def destroy
  @image = Image.find(params[:id])
  @image.destroy
  redirect_to admin_images_path
end

#editObject



29
30
31
# File 'app/controllers/admin/images_controller.rb', line 29

def edit
  @image = Image.find(params[:id])
end

#indexObject



11
12
13
14
# File 'app/controllers/admin/images_controller.rb', line 11

def index
  @search = Image.search(params[:search])
  @images = @search.order(:title).page(params[:page])
end

#newObject



16
17
18
# File 'app/controllers/admin/images_controller.rb', line 16

def new
  @image = Image.new
end

#updateObject



33
34
35
36
37
38
39
40
# File 'app/controllers/admin/images_controller.rb', line 33

def update
  @image = Image.find(params[:id])
  if @image.update_attributes(params[:image])
    redirect_to admin_images_path
  else
    render :edit
  end
end