OSDN Git Service

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