Class: OnboardOnRails::Admin::StepsController

Inherits:
BaseController show all
Defined in:
app/controllers/onboard_on_rails/admin/steps_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#current_user

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
# File 'app/controllers/onboard_on_rails/admin/steps_controller.rb', line 11

def create
  @step = @tour.steps.build(step_params)
  @step.position ||= @tour.steps.count
  if @step.save
    redirect_to edit_admin_tour_path(@tour), notice: t("onboard_on_rails.flash.step_created")
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



32
33
34
35
# File 'app/controllers/onboard_on_rails/admin/steps_controller.rb', line 32

def destroy
  @step.destroy
  redirect_to edit_admin_tour_path(@tour), notice: t("onboard_on_rails.flash.step_deleted")
end

#editObject



21
22
# File 'app/controllers/onboard_on_rails/admin/steps_controller.rb', line 21

def edit
end

#newObject



7
8
9
# File 'app/controllers/onboard_on_rails/admin/steps_controller.rb', line 7

def new
  @step = @tour.steps.build(position: @tour.steps.count + 1)
end

#updateObject



24
25
26
27
28
29
30
# File 'app/controllers/onboard_on_rails/admin/steps_controller.rb', line 24

def update
  if @step.update(step_params)
    redirect_to edit_admin_tour_step_path(@tour, @step), notice: t("onboard_on_rails.flash.step_updated")
  else
    render :edit, status: :unprocessable_entity
  end
end