Class: TaxGroupsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- TaxGroupsController
- Defined in:
- app/controllers/tax_groups_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /tax_groups.
-
#destroy ⇒ Object
DELETE /tax_groups/1.
-
#edit ⇒ Object
GET /tax_groups/1/edit.
-
#index ⇒ Object
GET /tax_groups.
-
#new ⇒ Object
GET /tax_groups/new.
-
#show ⇒ Object
GET /tax_groups/1.
-
#update ⇒ Object
PATCH/PUT /tax_groups/1.
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
GET /tax_groups/1/edit
19 20 |
# File 'app/controllers/tax_groups_controller.rb', line 19 def edit end |
#index ⇒ Object
GET /tax_groups
5 6 7 |
# File 'app/controllers/tax_groups_controller.rb', line 5 def index @tax_groups = TaxGroup.all end |
#new ⇒ Object
GET /tax_groups/new
14 15 16 |
# File 'app/controllers/tax_groups_controller.rb', line 14 def new @tax_group = TaxGroup.new end |
#show ⇒ Object
GET /tax_groups/1
10 11 |
# File 'app/controllers/tax_groups_controller.rb', line 10 def show end |
#update ⇒ Object
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 |