RS IZ a nicer fail(notice) on wrong file format on upload
This commit is contained in:
parent
8f70fb89c0
commit
082274d0d7
1 changed files with 16 additions and 7 deletions
|
|
@ -2,14 +2,23 @@ class PhotosController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@photo = Photo.instantiate(params[:photo])
|
begin
|
||||||
@photo.person = current_user
|
@photo = Photo.instantiate(params[:photo])
|
||||||
|
@photo.person = current_user
|
||||||
|
|
||||||
if @photo.save
|
|
||||||
flash[:notice] = "Successfully uploaded photo."
|
|
||||||
redirect_to @photo.album
|
|
||||||
else
|
if @photo.save
|
||||||
render :action => 'album#new'
|
flash[:notice] = "Successfully uploaded photo."
|
||||||
|
redirect_to @photo.album
|
||||||
|
else
|
||||||
|
render :action => 'album#new'
|
||||||
|
end
|
||||||
|
|
||||||
|
rescue
|
||||||
|
flash[:error] = "Photo upload failed. Are you sure that was an image?"
|
||||||
|
redirect_to Album.first(:id => params[:photo][:album_id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue