Class: InvoiceBar::InvoiceTemplatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- InvoiceBar::InvoiceTemplatesController
- Defined in:
- app/controllers/invoice_bar/invoice_templates_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /invoice_templates/1 POST /invoice_templates/1.json.
-
#destroy ⇒ Object
DELETE /invoice_templates/1 DELETE /invoice_templates/1.json.
-
#edit ⇒ Object
GET /invoice_templates/1/edit.
-
#index ⇒ Object
GET /invoice_templates GET /invoice_templates.json.
-
#new ⇒ Object
GET /invoice_templates/new.
-
#show ⇒ Object
GET /invoice_templates/1 GET /invoice_templates/1.json.
-
#update ⇒ Object
PATCH/PUT /invoices/1 PATCH/PUT /invoices/1.json.
Instance Method Details
#create ⇒ Object
POST /invoice_templates/1 POST /invoice_templates/1.json
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/invoice_bar/invoice_templates_controller.rb', line 37 def create flash[:notice], flash[:alert] = nil, nil @invoice_template = InvoiceTemplate.new(invoice_template_params) fill_in_contact if params[:fill_in_contact] if params[:tax_id] if (@invoice_template.load_contact_from_tax_id(@invoice_template.contact_tax_id)) flash[:notice] = I18n.t('messages.tax_id_loaded') else flash[:alert] = I18n.t('messages.cannot_load_tax_id') end end if params[:fill_in_contact] || params[:tax_id] respond_on_new @invoice_template else current_user.invoice_templates << @invoice_template respond_on_create @invoice_template end end |
#destroy ⇒ Object
DELETE /invoice_templates/1 DELETE /invoice_templates/1.json
90 91 92 93 |
# File 'app/controllers/invoice_bar/invoice_templates_controller.rb', line 90 def destroy @invoice_template.destroy respond_on_destroy @invoice_template, invoice_templates_url end |
#edit ⇒ Object
GET /invoice_templates/1/edit
61 62 63 64 |
# File 'app/controllers/invoice_bar/invoice_templates_controller.rb', line 61 def edit @invoice_template.build_address unless @invoice_template.address respond_on_edit @invoice_template end |
#index ⇒ Object
GET /invoice_templates GET /invoice_templates.json
10 11 12 13 |
# File 'app/controllers/invoice_bar/invoice_templates_controller.rb', line 10 def index @invoice_templates = current_user.invoice_templates.page(params[:page]) respond_on_index @invoice_templates end |
#new ⇒ Object
GET /invoice_templates/new
28 29 30 31 32 33 |
# File 'app/controllers/invoice_bar/invoice_templates_controller.rb', line 28 def new @invoice_template = InvoiceTemplate.new @invoice_template.items.build @invoice_template.build_address respond_on_new @invoice_template end |
#show ⇒ Object
GET /invoice_templates/1 GET /invoice_templates/1.json
17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/invoice_bar/invoice_templates_controller.rb', line 17 def show @address = @invoice_template.address unless @invoice_template.account_id or current_user.accounts @account = current_user.accounts.find(@invoice_template.account_id) end respond_on_show @invoice_template end |
#update ⇒ Object
PATCH/PUT /invoices/1 PATCH/PUT /invoices/1.json
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/controllers/invoice_bar/invoice_templates_controller.rb', line 68 def update flash[:notice], flash[:alert] = nil, nil fill_in_contact if params[:fill_in_contact] if params[:tax_id] if (@invoice_template.load_contact_from_tax_id(@invoice_template.contact_tax_id)) flash[:notice] = I18n.t('messages.tax_id_loaded') else flash[:alert] = I18n.t('messages.cannot_load_tax_id') end end if params[:fill_in_contact] || params[:tax_id] respond_on_edit @invoice_template else respond_on_update @invoice_template, invoice_template_params end end |