Class: Public::PagesController
- Inherits:
-
BaseController
- Object
- BaseController
- Public::PagesController
- Defined in:
- app/controllers/hicube/public/pages_controller.rb
Instance Method Summary collapse
Instance Method Details
#edit ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/hicube/public/pages_controller.rb', line 45 def edit filename = "#{Rails.root}/tmp/#{@page}_#{Process.pid}.slim" f = File.new(filename, "w+") f.write ::Liquid::Template.parse(@page.body).render f.close @page_content = ::Slim::Template.new(filename).render(Object.new, links: Hicube::Page.parents.map(&:slug), header_links: Hicube::Page.parents.headers.map(&:slug), footer_links: Hicube::Page.parents..map(&:slug), documents: Hicube::Document.all, id: @page.slug ) end |
#mail ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/hicube/public/pages_controller.rb', line 25 def mail PageMailer.notify(page_params).deliver_now respond_to do |format| format.html { if params[:page].has_key?(:success_page) redirect_to "/#{params[:page][:success_page]}" else redirect_to :back, flash: {success: "Message Sent! We will be in touch shortly."} end } format.json { render json: 'Message sent!', status: 200} end rescue respond_to do |format| format.html { redirect_to :back } format.json { render json: page_params, status: :unprocessable_entity } end end |
#show ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/hicube/public/pages_controller.rb', line 7 def show filename = "#{Rails.root}/tmp/#{@page}_#{Process.pid}.slim" f = File.new(filename, "w+") f.write ::Liquid::Template.parse(@page.body).render f.close @page_content = ::Slim::Template.new(filename).render(Object.new, links: Hicube::Page.parents.map(&:slug), header_links: Hicube::Page.parents.headers.map(&:slug), footer_links: Hicube::Page.parents..map(&:slug), documents: Hicube::Document.all, id: @page.slug ) rescue Exception => e logger.error "Error: Rendering #{@page} failed." logger.error e end |