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




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

def create
  # Find any existing list with the same name (case insensitive)
  if @list = List.find(:first, :conditions => ["lower(name) = ?", params[:list][:name].downcase])
    @list.update_attributes(params[:list])
  else
    @list = List.create(params[:list])
  end

  respond_with(@list)
end

#destroyObject

DELETE /lists/1




23
24
25
26
27
28
# File 'app/controllers/lists_controller.rb', line 23

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

  respond_with(@list)
end