Class: EntriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/entries_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /entries POST /entries.xml



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/entries_controller.rb', line 42

def create
  @entry = Entry.new(params[:entry])

  respond_to do |format|
    if @entry.save
      format.html { redirect_to(@entry, :notice => 'Entry was successfully created.') }
      format.xml  { render :xml => @entry, :status => :created, :location => @entry }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @entry.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /entries/1 DELETE /entries/1.xml



74
75
76
77
78
79
80
81
82
# File 'app/controllers/entries_controller.rb', line 74

def destroy
  @entry = Entry.find(params[:id])
  @entry.destroy

  respond_to do |format|
    format.html { redirect_to(entries_url) }
    format.xml  { head :ok }
  end
end

#editObject

GET /entries/1/edit



36
37
38
# File 'app/controllers/entries_controller.rb', line 36

def edit
  @entry = Entry.find(params[:id])
end

#indexObject

GET /entries GET /entries.xml



4
5
6
7
8
9
10
11
# File 'app/controllers/entries_controller.rb', line 4

def index
  @entries = Entry.all

  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render :xml => @entries }
  end
end

#newObject

GET /entries/new GET /entries/new.xml



26
27
28
29
30
31
32
33
# File 'app/controllers/entries_controller.rb', line 26

def new
  @entry = Entry.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @entry }
  end
end

#showObject

GET /entries/1 GET /entries/1.xml



15
16
17
18
19
20
21
22
# File 'app/controllers/entries_controller.rb', line 15

def show
  @entry = Entry.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.xml  { render :xml => @entry }
  end
end

#updateObject

PUT /entries/1 PUT /entries/1.xml



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/entries_controller.rb', line 58

def update
  @entry = Entry.find(params[:id])

  respond_to do |format|
    if @entry.update_attributes(params[:entry])
      format.html { redirect_to(@entry, :notice => 'Entry was successfully updated.') }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @entry.errors, :status => :unprocessable_entity }
    end
  end
end