class Public::AnnoncePhotosController < ApplicationController layout "public" def show @annonce = Annonce.find(params[:id]) end def new @annonce = Annonce.new() end def edit @annonce = Annonce.find(params[:id]) end def create @image_create = true @annonce = Annonce.find(params[:annonce_id]) @annonce_photo = AnnoncePhoto.new(:annonce_id => params[:annonce_id], :file =>params[:files], :enabled => true) if @annonce_photo.annonce.annonce_photos.visibles.count < @annonce_photo.annonce.nbr_photos.to_i if @annonce_photo.save else end end end def confirm @annonce = Annonce.find_by_token(params[:id]) @annonce.enabled = true @annonce.save cookies[:annonce_auth_token] = @annonce.token redirect_to public_my_account_path #redirect_to "/" end def update @annonce = Annonce.find(params[:id]) if @annonce == current_annonce if @annonce.update_attributes(params.require(:annonce).permit!) redirect_to public_my_account_path else render :action => "edit" end end end def destroy @annonce_photo = current_annonce_account.annonce_photos.find(params[:id]) @annonce = @annonce_photo.annonce @annonce_photo.deleted = true @annonce_photo.save #@annonce = Annonce.find(params[:id]) #@annonce.destroy end def rotate deg = params[:direction] == "right" ? -90 : 90 @annonce_photo = AnnoncePhoto.find(params[:id]) @annonce_photo.rotate(deg) end end