Class: News::NewsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/news/news_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /news POST /news.xml



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/news/news_controller.rb', line 46

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

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

#destroyObject

DELETE /news/1 DELETE /news/1.xml



78
79
80
81
82
83
84
85
86
# File 'app/controllers/news/news_controller.rb', line 78

def destroy
  @new = New.find(params[:id])
  @new.destroy

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

#editObject

GET /news/1/edit



40
41
42
# File 'app/controllers/news/news_controller.rb', line 40

def edit
  @new = New.find(params[:id])
end

#indexObject

GET /news GET /news.xml



8
9
10
11
12
13
14
15
# File 'app/controllers/news/news_controller.rb', line 8

def index
  @news = New.all

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

#newObject

GET /news/new GET /news/new.xml



30
31
32
33
34
35
36
37
# File 'app/controllers/news/news_controller.rb', line 30

def new
  @new = New.new

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

#showObject

GET /news/1 GET /news/1.xml



19
20
21
22
23
24
25
26
# File 'app/controllers/news/news_controller.rb', line 19

def show
  @new = New.find(params[:id])

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

#updateObject

PUT /news/1 PUT /news/1.xml



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/controllers/news/news_controller.rb', line 62

def update
  @new = New.find(params[:id])

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