Class: Admin::ChangesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/stenographer/admin/changes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 13

def create
  @change = Change.new(change_params)
  @change.environments = Rails.env.to_s.downcase

  if @change.save
    redirect_to admin_change_path(@change), notice: 'Change Created'
  else
    flash.now[:alert] = @change.errors.full_messages.to_sentence
    render :new
  end
end

#destroyObject



47
48
49
50
51
52
53
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 47

def destroy
  if @change.destroy
    redirect_to admin_changes_path, notice: 'Change Destroyed'
  else
    redirect_to admin_change_path(@change), alert: @change.errors.full_messages.to_sentence
  end
end

#editObject



32
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 32

def edit; end

#indexObject



25
26
27
28
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 25

def index
  page = params[:page] || 1
  @changes = Change.order(created_at: :desc).paginate(page: page, per_page: Stenographer.per_page)
end

#newObject



9
10
11
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 9

def new
  @change = Change.new
end

#showObject



30
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 30

def show; end

#updateObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/stenographer/admin/changes_controller.rb', line 34

def update
  message = {}

  if @change.update(change_params)
    message[:notice] = 'Change Updated'

    redirect_to admin_change_path(@change), message
  else
    flash.now[:alert] = @change.errors.full_messages.to_sentence
    render :edit
  end
end