Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Admin
- class Photos < Application
- before :set_parent
- def create
- # @photo = Photo.new(file)
- @photo = Photo.new
- @photo.file = params[:file]
- if @photo.save
- @parent.photos << @photo
- redirect resource(:admin, @parent), :message => {:notice => "Photo was successfully uploaded"}
- else
- message[:error] = "Photo failed to be uploaded"
- render :new
- end
- end
- private
- def set_parent
- # case params[:parent]
- # when 'admin/shows'
- # @parent = Show.get(params[:id])
- # end
- if params[:show_id]
- @parent = Show.get(params[:show_id])
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment