Sha256: 87c4b0736f77358dc8afe3b4e78e839b026266a2fb0f965c0482abbafafc57e8
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
require_dependency "customer_vault/application_controller" module CustomerVault class CorporationsController < ApplicationController before_action :set_corporation, only: [:show, :edit, :update, :destroy] # GET /corporations/1 def show authorize! :read, @corporation end # GET /corporations/new def new authorize! :create, CustomerVault::Corporation @corporation = Corporation.new @corporation.build_address end # GET /corporations/1/edit def edit authorize! :update, @corporation @corporation.build_address unless @corporation.address end # POST /corporations def create authorize! :create, CustomerVault::Corporation @corporation = Corporation.new(corporation_params) if @corporation.save redirect_to @corporation, notice: 'Corporation was successfully created.' else render action: 'new' end end # PATCH/PUT /corporations/1 def update authorize! :update, @corporation if @corporation.update(corporation_params) redirect_to @corporation, notice: 'Corporation was successfully updated.' else render action: 'edit' end end # DELETE /corporations/1 def destroy authorize! :delete, @corporation @corporation.destroy redirect_to people_url, notice: 'Corporation was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_corporation @corporation = Corporation.find(params[:id]) end # Only allow a trusted parameter "white list" through. def corporation_params params.require(:corporation).permit(:name, :email, :phone, :fax, :address_attributes => [:street, :street_bis, :zip, :city, :country]) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
customer_vault-1.2.0 | app/controllers/customer_vault/corporations_controller.rb |