Class: Rooler::TemplatesController
- Inherits:
-
ApplicationController
- Object
- BaseController
- ApplicationController
- Rooler::TemplatesController
- Includes:
- ApplicationHelper
- Defined in:
- app/controllers/rooler/templates_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /templates.
-
#destroy ⇒ Object
DELETE /templates/1.
-
#edit ⇒ Object
GET /templates/1/edit.
-
#index ⇒ Object
GET /templates.
-
#new ⇒ Object
GET /templates/new.
-
#show ⇒ Object
GET /templates/1.
- #test ⇒ Object
-
#update ⇒ Object
PATCH/PUT /templates/1.
Methods included from ApplicationHelper
Instance Method Details
#create ⇒ Object
POST /templates
47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/rooler/templates_controller.rb', line 47 def create @template = Template.new(template_params) if @template.save redirect_to @template, notice: 'Template was successfully created.' else render action: 'new' end end |
#destroy ⇒ Object
DELETE /templates/1
67 68 69 70 |
# File 'app/controllers/rooler/templates_controller.rb', line 67 def destroy @template.destroy redirect_to templates_url, notice: 'Template was successfully destroyed.' end |
#edit ⇒ Object
GET /templates/1/edit
43 44 |
# File 'app/controllers/rooler/templates_controller.rb', line 43 def edit end |
#index ⇒ Object
GET /templates
23 24 25 |
# File 'app/controllers/rooler/templates_controller.rb', line 23 def index @templates = Template.order(:created_at) end |
#new ⇒ Object
GET /templates/new
38 39 40 |
# File 'app/controllers/rooler/templates_controller.rb', line 38 def new @template = Template.new end |
#show ⇒ Object
GET /templates/1
28 29 30 31 32 33 34 35 |
# File 'app/controllers/rooler/templates_controller.rb', line 28 def show test_object = @template.test_object if test_object @liquid_variables = {test_object.class.name.demodulize.downcase.to_s => test_object} else flash.now[:notice] ||= "Variables may be empty. Searched the rules associated with this template but couldn't find any objects to test with." end end |
#test ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/rooler/templates_controller.rb', line 10 def test test_object = @template.test_object deliverable = Delivery.new(deliverable: test_object, template: @template) if test_object delivery = DeliveryMailer.send_mail(deliverable, params[:email]).deliver if deliverable if delivery redirect_to @template, notice: "Test email sent" else notice = test_object ? "Failed. Couldn't deliver email" : "Failed. Searched the rules associated with this template but couldn't find any objects to test with." redirect_to @template, notice: notice end end |
#update ⇒ Object
PATCH/PUT /templates/1
58 59 60 61 62 63 64 |
# File 'app/controllers/rooler/templates_controller.rb', line 58 def update if @template.update(template_params) redirect_to @template, notice: 'Template was successfully updated.' else render action: 'edit' end end |