OSDN Git Service

8f2ac7a8014f095304656ffbe8bdbfd039487e94
[tdcgexplorer/nimono.git] / app / controllers / thumbs_controller.rb
1 class ThumbsController < ApplicationController
2   layout 'arcs'
3
4   # GET /thumbs
5   # GET /thumbs.xml
6   def index
7     @thumbs = Thumb.paginate(:page => params[:page])
8
9     respond_to do |format|
10       format.html # index.html.erb
11       format.xml  { render :xml => @thumbs }
12     end
13   end
14
15   # GET /thumbs/1
16   # GET /thumbs/1.xml
17   def show
18     @thumb = Thumb.find(params[:id])
19
20     respond_to do |format|
21       format.html # show.html.erb
22       format.xml  { render :xml => @thumb }
23     end
24   end
25
26   # GET /thumbs/new
27   # GET /thumbs/new.xml
28   def new
29     @thumb = Thumb.new
30
31     respond_to do |format|
32       format.html # new.html.erb
33       format.xml  { render :xml => @thumb }
34     end
35   end
36
37   # GET /thumbs/1/edit
38   def edit
39     @thumb = Thumb.find(params[:id])
40   end
41
42   # POST /thumbs
43   # POST /thumbs.xml
44   def create
45     @thumb = Thumb.new(params[:thumb])
46     @thumb.video_id = params[:thumb].delete(:video_id)
47
48     respond_to do |format|
49       if @thumb.save
50         flash[:notice] = 'Thumb was successfully created.'
51         format.html { redirect_to(@thumb) }
52         format.xml  { render :xml => @thumb, :status => :created, :location => @thumb }
53       else
54         format.html { render :action => "new" }
55         format.xml  { render :xml => @thumb.errors, :status => :unprocessable_entity }
56       end
57     end
58   end
59
60   # PUT /thumbs/1
61   # PUT /thumbs/1.xml
62   def update
63     @thumb = Thumb.find(params[:id])
64
65     respond_to do |format|
66       if @thumb.update_attributes(params[:thumb])
67         flash[:notice] = 'Thumb was successfully updated.'
68         format.html { redirect_to(@thumb) }
69         format.xml  { head :ok }
70       else
71         format.html { render :action => "edit" }
72         format.xml  { render :xml => @thumb.errors, :status => :unprocessable_entity }
73       end
74     end
75   end
76
77   # DELETE /thumbs/1
78   # DELETE /thumbs/1.xml
79   def destroy
80     @thumb = Thumb.find(params[:id])
81     @thumb.destroy
82
83     respond_to do |format|
84       format.html { redirect_to(thumbs_url) }
85       format.xml  { head :ok }
86     end
87   end
88 end