summaryrefslogtreecommitdiff
path: root/app/controllers/occurrences_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/occurrences_controller.rb')
-rw-r--r--app/controllers/occurrences_controller.rb85
1 files changed, 85 insertions, 0 deletions
diff --git a/app/controllers/occurrences_controller.rb b/app/controllers/occurrences_controller.rb
new file mode 100644
index 0000000..e3f1cdd
--- /dev/null
+++ b/app/controllers/occurrences_controller.rb
@@ -0,0 +1,85 @@
1class OccurrencesController < ApplicationController
2 # GET /occurrences
3 # GET /occurrences.xml
4 def index
5 @occurrences = Occurrence.all
6
7 respond_to do |format|
8 format.html # index.html.erb
9 format.xml { render :xml => @occurrences }
10 end
11 end
12
13 # GET /occurrences/1
14 # GET /occurrences/1.xml
15 def show
16 @occurrence = Occurrence.find(params[:id])
17
18 respond_to do |format|
19 format.html # show.html.erb
20 format.xml { render :xml => @occurrence }
21 end
22 end
23
24 # GET /occurrences/new
25 # GET /occurrences/new.xml
26 def new
27 @occurrence = Occurrence.new
28
29 respond_to do |format|
30 format.html # new.html.erb
31 format.xml { render :xml => @occurrence }
32 end
33 end
34
35 # GET /occurrences/1/edit
36 def edit
37 @occurrence = Occurrence.find(params[:id])
38 end
39
40 # POST /occurrences
41 # POST /occurrences.xml
42 def create
43 @occurrence = Occurrence.new(params[:occurrence])
44
45 respond_to do |format|
46 if @occurrence.save
47 flash[:notice] = 'Occurrence was successfully created.'
48 format.html { redirect_to(@occurrence) }
49 format.xml { render :xml => @occurrence, :status => :created, :location => @occurrence }
50 else
51 format.html { render :action => "new" }
52 format.xml { render :xml => @occurrence.errors, :status => :unprocessable_entity }
53 end
54 end
55 end
56
57 # PUT /occurrences/1
58 # PUT /occurrences/1.xml
59 def update
60 @occurrence = Occurrence.find(params[:id])
61
62 respond_to do |format|
63 if @occurrence.update_attributes(params[:occurrence])
64 flash[:notice] = 'Occurrence was successfully updated.'
65 format.html { redirect_to(@occurrence) }
66 format.xml { head :ok }
67 else
68 format.html { render :action => "edit" }
69 format.xml { render :xml => @occurrence.errors, :status => :unprocessable_entity }
70 end
71 end
72 end
73
74 # DELETE /occurrences/1
75 # DELETE /occurrences/1.xml
76 def destroy
77 @occurrence = Occurrence.find(params[:id])
78 @occurrence.destroy
79
80 respond_to do |format|
81 format.html { redirect_to(occurrences_url) }
82 format.xml { head :ok }
83 end
84 end
85end