Class: ListsController

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

Overview

Copyright © 2008-2013 Michael Dvorkin and contributors.

Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php


Instance Method Summary collapse

Methods inherited from ApplicationController

#auto_complete

Instance Method Details

#createObject

POST /lists




11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/lists_controller.rb', line 11

def create
  list_attr = list_params.to_h
  list_attr["user_id"] = current_user.id if params["is_global"] != "1"

  # Find any existing list with the same name (case insensitive)
  if @list = List.where("lower(name) = ?", list_attr[:name].downcase).where(user_id: list_attr[:user_id]).first
    @list.update(list_attr)
  else
    @list = List.create(list_attr)
  end

  respond_with(@list)
end

#destroyObject

DELETE /lists/1




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

def destroy
  @list = List.find(params[:id])
  @list.destroy

  respond_with(@list)
end