Class: PhotosController

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

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
# File 'app/controllers/photos_controller.rb', line 14

def create
	@photo = Photo.new(params[:photo])
	@photo.save!
	redirect_to @photo
rescue ActiveRecord::RecordInvalid
	flash.now[:error] = "Error"
	render :action => 'new'
end

#destroyObject



31
32
33
34
# File 'app/controllers/photos_controller.rb', line 31

def destroy
	@photo.destroy
	redirect_to photos_path
end

#indexObject



6
7
8
# File 'app/controllers/photos_controller.rb', line 6

def index
	@photos = Photo.all
end

#newObject



10
11
12
# File 'app/controllers/photos_controller.rb', line 10

def new
	@photo = Photo.new
end

#updateObject



23
24
25
26
27
28
29
# File 'app/controllers/photos_controller.rb', line 23

def update
	@photo.update_attributes!(params[:photo])
	redirect_to @photo
rescue ActiveRecord::RecordInvalid
	flash.now[:error] = "Error"
	render :action => 'edit'
end