forked from huacnlee/personlab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
shares_controller.rb
85 lines (73 loc) · 1.9 KB
/
shares_controller.rb
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class SharesController < ApplicationController
# GET /shares
# GET /shares.xml
def index
@shares = Share.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @shares }
end
end
# GET /shares/1
# GET /shares/1.xml
def show
@share = Share.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @share }
end
end
# GET /shares/new
# GET /shares/new.xml
def new
@share = Share.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @share }
end
end
# GET /shares/1/edit
def edit
@share = Share.find(params[:id])
end
# POST /shares
# POST /shares.xml
def create
@share = Share.new(params[:share])
respond_to do |format|
if @share.save
flash[:notice] = 'Share was successfully created.'
format.html { redirect_to(@share) }
format.xml { render :xml => @share, :status => :created, :location => @share }
else
format.html { render :action => "new" }
format.xml { render :xml => @share.errors, :status => :unprocessable_entity }
end
end
end
# PUT /shares/1
# PUT /shares/1.xml
def update
@share = Share.find(params[:id])
respond_to do |format|
if @share.update_attributes(params[:share])
flash[:notice] = 'Share was successfully updated.'
format.html { redirect_to(@share) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @share.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /shares/1
# DELETE /shares/1.xml
def destroy
@share = Share.find(params[:id])
@share.destroy
respond_to do |format|
format.html { redirect_to(shares_url) }
format.xml { head :ok }
end
end
end