Class: PagesController

Inherits:
ApplicationController show all
Includes:
Applicat::Mvc::Controller::Resource
Defined in:
app/controllers/pages_controller.rb

Instance Method Summary collapse

Methods included from Applicat::Mvc::Controller::Resource

included

Methods inherited from ApplicationController

#current_ability

Methods included from Voluntary::V1::BaseController

#parent, #voluntary_application_javascripts, #voluntary_application_stylesheets

Methods included from Applicat::Mvc::Controller

included

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/pages_controller.rb', line 20

def create
  @page = Page.new(params[:page])
  @page.user = current_user
  
  if @page.save
    redirect_to @page, notice: t('general.form.successfully_created')
  else
    render :new
  end
end

#destroyObject



45
46
47
48
49
# File 'app/controllers/pages_controller.rb', line 45

def destroy
  @page = Page.find(params[:id])
  @page.destroy
  redirect_to pages_url, notice: t('general.form.destroyed')
end

#editObject



31
32
33
# File 'app/controllers/pages_controller.rb', line 31

def edit
  @page = Page.find(params[:id])
end

#indexObject



8
9
10
# File 'app/controllers/pages_controller.rb', line 8

def index
  @pages = Page.order_by(name: 'ASC')
end

#newObject



16
17
18
# File 'app/controllers/pages_controller.rb', line 16

def new
  @page = Page.new
end

#resourceObject



51
52
53
# File 'app/controllers/pages_controller.rb', line 51

def resource
  @page
end

#showObject



12
13
14
# File 'app/controllers/pages_controller.rb', line 12

def show
  @page = Page.find(params[:id])
end

#updateObject



35
36
37
38
39
40
41
42
43
# File 'app/controllers/pages_controller.rb', line 35

def update
  @page = Page.find(params[:id])
  
  if @page.update_attributes(params[:page])
    redirect_to @page, notice: t('general.form.successfully_updated')
  else
    render :edit
  end
end