Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class ThingsController < ApplicationController
  make_resourceful do
    actions :all
  end
  
  def create
    @thing = Thing.new(params[:thing])

    respond_to do |format|
      if @thing.save
        flash[:notice] = 'Thing was successfully created.'
        format.html { redirect_to thing_url(@thing) }
      else
        format.html { render :action => "new" }
      end
    end
  end
  
  def update
      @thing = Thing.find(params[:id])
  
      respond_to do |format|
        if @thing.update_attributes(params[:thing])
          flash[:notice] = 'Thing was successfully updated.'
          format.html { redirect_to thing_url(@thing) }
        else
          format.html { render :action => "edit" }
        end
      end
    end
  
    def destroy
      @thing = Thing.find(params[:id])
      @thing.destroy
  
      respond_to do |format|
        format.html { redirect_to things_url }
      end
    end
end