OSDN Git Service

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