Class: InnerPlan::ListsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/inner_plan/lists_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/inner_plan/lists_controller.rb', line 18

def create
  @list = InnerPlan::List.new(list_params)
  @list.user = current_inner_plan_user

  if @list.save
    redirect_to lists_path
  else
    render InnerPlan::Lists::NewView.new(list: @list), status: :unprocessable_entity
  end
end

#editObject



29
30
31
32
# File 'app/controllers/inner_plan/lists_controller.rb', line 29

def edit
  @list = InnerPlan::List.root.find(params[:id])
  render InnerPlan::Lists::EditView.new(list: @list)
end

#indexObject



3
4
5
6
# File 'app/controllers/inner_plan/lists_controller.rb', line 3

def index
  @lists = InnerPlan::List::Operation::Index.call[:models]
  render InnerPlan::Lists::IndexView.new(lists: @lists)
end

#newObject



13
14
15
16
# File 'app/controllers/inner_plan/lists_controller.rb', line 13

def new
  @list = InnerPlan::List.new
  render InnerPlan::Lists::NewView.new(list: @list)
end

#showObject



8
9
10
11
# File 'app/controllers/inner_plan/lists_controller.rb', line 8

def show
  @list = InnerPlan::List.root.find(params[:id])
  render InnerPlan::Lists::ShowView.new(list: @list)
end

#updateObject



34
35
36
37
38
39
40
41
# File 'app/controllers/inner_plan/lists_controller.rb', line 34

def update
  @list = InnerPlan::List.root.find(params[:id])
  if @list.update(list_params)
    redirect_to list_path(@list)
  else
    render InnerPlan::Lists::EditView.new(list: @list)
  end
end

#update_positionObject



43
44
45
46
47
# File 'app/controllers/inner_plan/lists_controller.rb', line 43

def update_position
  @list = InnerPlan::List.root.find(params[:id])
  @list.position = { before: update_positions_params[:position][:before] }
  @list.save!
end