Class: PagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/lean_cms/demo/templates/pages_controller.rb

Instance Method Summary collapse

Instance Method Details

#aboutObject



10
11
12
# File 'lib/generators/lean_cms/demo/templates/pages_controller.rb', line 10

def about
  @page = LeanCms::Page.find_by(slug: 'about')
end

#contactObject



14
15
16
# File 'lib/generators/lean_cms/demo/templates/pages_controller.rb', line 14

def contact
  @page = LeanCms::Page.find_by(slug: 'contact')
end

#homeObject



6
7
8
# File 'lib/generators/lean_cms/demo/templates/pages_controller.rb', line 6

def home
  @page = LeanCms::Page.find_by(slug: 'home')
end

#submit_contactObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/lean_cms/demo/templates/pages_controller.rb', line 18

def submit_contact
  LeanCms::FormSubmission.create!(
    name:    params[:name],
    email:   params[:email],
    message: params[:message]
  )
  redirect_to contact_path, notice: "Message sent!"
rescue ActiveRecord::RecordInvalid => e
  flash.now[:alert] = e.message
  @page = LeanCms::Page.find_by(slug: 'contact')
  render :contact, status: :unprocessable_entity
end