OSDN Git Service

import all source code
[pettanr/pettanr.git] / app / controllers / resource_pictures_controller.rb
1 class ResourcePicturesController < ApplicationController
2   before_filter :authenticate_author!, :except => [:index, :show]
3
4   # GET /resource_pictures
5   # GET /resource_pictures.json
6   def index
7     @resource_pictures = ResourcePicture.all
8
9     respond_to do |format|
10       format.html # index.html.erb
11       format.json { render json: @resource_pictures }
12     end
13   end
14
15   # GET /resource_pictures/1
16   # GET /resource_pictures/1.json
17   def show
18     @resource_picture = ResourcePicture.find(params[:id])
19
20     respond_to do |format|
21       opt = {:type => @resource_picture.mime_type, :disposition=>"inline"}
22       format.png { send_data(@resource_picture.restore(params[:subdir]), opt ) }
23       format.gif { send_data(@resource_picture.restore(params[:subdir]), opt ) }
24       format.jpeg { send_data(@resource_picture.restore(params[:subdir]), opt ) }
25       format.html # show.html.erb
26       format.json { render json: @resource_picture}
27     end
28   end
29
30 =begin
31   # GET /resource_pictures/new
32   # GET /resource_pictures/new.json
33   def new
34     @resource_picture = ResourcePicture.new
35
36     respond_to do |format|
37       format.html # new.html.erb
38       format.json { render json: @resource_picture }
39     end
40   end
41
42   # GET /resource_pictures/1/edit
43   def edit
44     @resource_picture = ResourcePicture.find(params[:id])
45   end
46
47   # POST /resource_pictures
48   # POST /resource_pictures.json
49   def create
50     @resource_picture = ResourcePicture.new(params[:resource_picture])
51
52     respond_to do |format|
53       if @resource_picture.save
54         format.html { redirect_to @resource_picture, notice: 'Resource picture was successfully created.' }
55         format.json { render json: @resource_picture, status: :created, location: @resource_picture }
56       else
57         format.html { render action: "new" }
58         format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
59       end
60     end
61   end
62
63   # PUT /resource_pictures/1
64   # PUT /resource_pictures/1.json
65   def update
66     @resource_picture = ResourcePicture.find(params[:id])
67
68     respond_to do |format|
69       if @resource_picture.update_attributes(params[:resource_picture])
70         format.html { redirect_to @resource_picture, notice: 'Resource picture was successfully updated.' }
71         format.json { head :ok }
72       else
73         format.html { render action: "edit" }
74         format.json { render json: @resource_picture.errors, status: :unprocessable_entity }
75       end
76     end
77   end
78
79   # DELETE /resource_pictures/1
80   # DELETE /resource_pictures/1.json
81   def destroy
82     @resource_picture = ResourcePicture.find(params[:id])
83     @resource_picture.destroy
84
85     respond_to do |format|
86       format.html { redirect_to resource_pictures_url }
87       format.json { head :ok }
88     end
89   end
90 =end
91 end