Class: GalleriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/galleries_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

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

#destroyObject



44
45
46
47
48
49
# File 'app/controllers/galleries_controller.rb', line 44

def destroy
  @gallery = Gallery.find(params[:id])
  @gallery.destroy
  flash[:notice] = "Successfully destroyed gallery."
  redirect_to galleries_url
end

#editObject



30
31
32
# File 'app/controllers/galleries_controller.rb', line 30

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

#indexObject



5
6
7
# File 'app/controllers/galleries_controller.rb', line 5

def index
  @galleries = Gallery.all
end

#newObject



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

def new
  @gallery = Gallery.new
  @gallery.build_index
end

#showObject



9
10
11
12
13
# File 'app/controllers/galleries_controller.rb', line 9

def show
  @gallery = Gallery.find(params[:id])
  @index = @gallery.index
  @photo = @gallery.photos.first
end

#updateObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/galleries_controller.rb', line 34

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