Class: Smithy::TemplatesController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Smithy::TemplatesController
- Defined in:
- app/controllers/smithy/templates_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #javascript ⇒ Object
- #new ⇒ Object
- #stylesheet ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/controllers/smithy/templates_controller.rb', line 18 def create @template = Template.new(filtered_params) @template.save flash.notice = "Your template was created" if @template.persisted? respond_with @template do |format| format.html { redirect_to [:edit, @template] } end end |
#destroy ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/smithy/templates_controller.rb', line 48 def destroy @template = Template.find(params[:id]) @template.destroy respond_with @template end |
#edit ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/smithy/templates_controller.rb', line 27 def edit @template = Template.find(params[:id]) @template_editor_type = case @template.template_type when 'javascript' 'javascript' when 'stylesheet' 'css' else 'liquid' end respond_with @template end |
#index ⇒ Object
9 10 11 |
# File 'app/controllers/smithy/templates_controller.rb', line 9 def index respond_with @templates end |
#javascript ⇒ Object
54 55 56 57 |
# File 'app/controllers/smithy/templates_controller.rb', line 54 def javascript @javascript = Template.javascripts.find_by(name: params[:javascript].sub(/\.js$/, '')) render_asset_template(@javascript, params[:javascript], 'text/javascript') end |
#new ⇒ Object
13 14 15 16 |
# File 'app/controllers/smithy/templates_controller.rb', line 13 def new @template = Template.new(filtered_params) respond_with @template end |
#stylesheet ⇒ Object
59 60 61 62 |
# File 'app/controllers/smithy/templates_controller.rb', line 59 def stylesheet @stylesheet = Template.stylesheets.find_by(name: params[:stylesheet].sub(/\.css$/, '')) render_asset_template(@stylesheet, params[:stylesheet], 'text/css') end |
#update ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/controllers/smithy/templates_controller.rb', line 40 def update @template = Template.find(params[:id]) flash.notice = "Your template was saved" if @template.update_attributes(filtered_params) respond_with @template do |format| format.html { redirect_to [:edit, @template] } end end |