vita_app/app/controllers/public/account_ribs_controller.rb
Nicolas Bally d52c017848 suite
2016-04-28 22:41:58 +02:00

103 lines
1.6 KiB
Ruby

class Public::AccountRibsController < ApplicationController
layout "public"
before_filter :auth_product_customer
def index
@account_rib = current_product_customer.account_ribs.all
end
def show
@account_rib = AccountRib.find(params[:id])
session[:mail_prev] = public_account_rib_path(@account_rib)
end
def new
@no_search = true
@account_rib = current_product_customer.account_ribs.new(:country => "France")
end
def edit
@account_rib = current_account_rib_account.account_rib.find(params[:id])
end
def create
@account_rib = current_product_customer.account_ribs.new(params.require(:account_rib).permit!)
if @account_rib.save
redirect_to public_account_ribs_path
else
render :action => "new"
end
end
def update
@account_rib = current_product_customer.account_ribs.find(params[:id])
respond_to do |format|
if @account_rib.update_attributes(params.require(:account_rib).permit!)
format.html {
redirect_to public_my_account_path
}
format.js
else
format.html { render :action => "edit" }
format.js { "" }
end
end
end
def destroy
@account_rib = current_account_rib_account.account_rib.find(params[:id])
@account_rib.enabled = nil
@account_rib.save
redirect_to public_my_account_path, :notice => "Votre account_rib a bien été désactivée"
end
end