still figuring out git
[custlog.git] / app / controllers / entries_controller.rb
blob49de17ef665b93ce20b695295314cbf51cf728a8
1 class EntriesController < ApplicationController
2   # GET /entries
3   # GET /entries.xml
4   def index
5     @entries = Entry.find(:all)
7     respond_to do |format|
8       format.html # index.html.erb
9       format.xml  { render :xml => @entries }
10     end
11   end
13   # GET /entries/1
14   # GET /entries/1.xml
15   def show
16     @entry = Entry.find(params[:id])
18     respond_to do |format|
19       format.html # show.html.erb
20       format.xml  { render :xml => @entry }
21     end
22   end
24   # GET /entries/new
25   # GET /entries/new.xml
26   def new
27     @entry = Entry.new
29     respond_to do |format|
30       format.html # new.html.erb
31       format.xml  { render :xml => @entry }
32     end
33   end
35   # GET /entries/1/edit
36   def edit
37     @entry = Entry.find(params[:id])
38   end
40   # POST /entries
41   # POST /entries.xml
42   def create
43     @entry = Entry.new(params[:entry])
45     respond_to do |format|
46       if @entry.save
47         flash[:notice] = 'Entry was successfully created.'
48         format.html { redirect_to(@entry) }
49         format.xml  { render :xml => @entry, :status => :created, :location => @entry }
50       else
51         format.html { render :action => "new" }
52         format.xml  { render :xml => @entry.errors, :status => :unprocessable_entity }
53       end
54     end
55   end
57   # PUT /entries/1
58   # PUT /entries/1.xml
59   def update
60     @entry = Entry.find(params[:id])
62     respond_to do |format|
63       if @entry.update_attributes(params[:entry])
64         flash[:notice] = 'Entry was successfully updated.'
65         format.html { redirect_to(@entry) }
66         format.xml  { head :ok }
67       else
68         format.html { render :action => "edit" }
69         format.xml  { render :xml => @entry.errors, :status => :unprocessable_entity }
70       end
71     end
72   end
74   # DELETE /entries/1
75   # DELETE /entries/1.xml
76   def destroy
77     @entry = Entry.find(params[:id])
78     @entry.destroy
80     respond_to do |format|
81       format.html { redirect_to(entries_url) }
82       format.xml  { head :ok }
83     end
84   end
85 end