Class: TaxGroupsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/tax_groups_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /tax_groups



23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/tax_groups_controller.rb', line 23

def create
  @tax_group = TaxGroup.new({name: params[:tax_group][:name]})
  params[:tax_group][:tax_group_items].each do |item|
    @tax_group.tax_group_items.build({ tax_id: item }).save unless item.empty?
  end

  if @tax_group.save
    redirect_to tax_groups_url, notice: 'Tax group was successfully created.'
  else
    render :new
  end
end

#destroyObject

DELETE /tax_groups/1



46
47
48
49
# File 'app/controllers/tax_groups_controller.rb', line 46

def destroy
  @tax_group.destroy
  redirect_to tax_groups_url, notice: 'Tax group was successfully destroyed.'
end

#editObject

GET /tax_groups/1/edit



19
20
# File 'app/controllers/tax_groups_controller.rb', line 19

def edit
end

#indexObject

GET /tax_groups



5
6
7
# File 'app/controllers/tax_groups_controller.rb', line 5

def index
  @tax_groups = TaxGroup.all
end

#newObject

GET /tax_groups/new



14
15
16
# File 'app/controllers/tax_groups_controller.rb', line 14

def new
  @tax_group = TaxGroup.new
end

#showObject

GET /tax_groups/1



10
11
# File 'app/controllers/tax_groups_controller.rb', line 10

def show
end

#updateObject

PATCH/PUT /tax_groups/1



37
38
39
40
41
42
43
# File 'app/controllers/tax_groups_controller.rb', line 37

def update
  if @tax_group.update(tax_group_params)
    redirect_to tax_groups_url, notice: 'Tax group was successfully updated.'
  else
    render :edit
  end
end