Class: ListsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#klass

Instance Method Details

#createObject

POST /lists




6
7
8
9
10
11
12
13
14
# File 'app/controllers/lists_controller.rb', line 6

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




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

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

  respond_with(@list)

rescue ActiveRecord::RecordNotFound
  respond_to_not_found(:html, :js, :json, :xml)
end