Class: PhotosController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @photo = Photo.new(params[:photo])
  @photo.product_id = params[:product_id]
  @photo.save!
  redirect_to :back
end

#destroyObject



13
14
15
16
17
# File 'app/controllers/photos_controller.rb', line 13

def destroy
  photo = Photo.find_by_id(params[:id])
  photo.destroy
  redirect_to :back
end

#newObject



2
3
4
# File 'app/controllers/photos_controller.rb', line 2

def new
  @product = Product.find_by_permalink(params['product_id']) || Product.find_by_id(params['product_id'])
end