Sha256: 873675119e036da057acc841563b0eae934598eb00135c6edda49bfa4e4c8a42
Contents?: true
Size: 1.69 KB
Versions: 5
Compression:
Stored size: 1.69 KB
Contents
require_dependency "customer_vault/application_controller" module CustomerVault class IndividualsController < ApplicationController helper Dorsale::CommentsHelper before_action :set_individual, only: [:show, :edit, :update, :destroy] def show authorize! :read, @individual end def new authorize! :create, CustomerVault::Individual @individual = Individual.new @individual.build_address end def edit authorize! :update, @individual @individual.build_address unless @individual.address end def create authorize! :create, CustomerVault::Individual @individual = Individual.new(individual_params) if @individual.save redirect_to @individual, notice: 'Individual was successfully created.' else render action: 'new' end end def update authorize! :update, @individual if @individual.update(individual_params) redirect_to @individual, notice: 'Individual was successfully updated.' else render action: 'edit' end end def destroy authorize! :delete, @individual @individual.destroy redirect_to people_url, notice: 'Individual was successfully destroyed.' end private def set_individual @individual = Individual.find(params[:id]) end def permitted_params [ :first_name, :last_name, :email, :title, :twitter, :www, :context, :phone, :fax, :mobile, :address_attributes => [:street, :street_bis, :zip, :city, :country] ] end def individual_params params.require(:individual).permit(permitted_params) end end end
Version data entries
5 entries across 5 versions & 1 rubygems