Class: Ems::NewsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Ems::NewsController
- Defined in:
- app/controllers/ems/news_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /news POST /news.json.
-
#destroy ⇒ Object
DELETE /news/1 DELETE /news/1.json.
-
#edit ⇒ Object
GET /news/1/edit.
-
#index ⇒ Object
GET /news GET /news.json.
-
#new ⇒ Object
GET /news/new GET /news/new.json.
-
#show ⇒ Object
GET /news/1 GET /news/1.json.
-
#update ⇒ Object
PUT /news/1 PUT /news/1.json.
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
POST /news POST /news.json
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/ems/news_controller.rb', line 47 def create @news = News.new(params[:news]) respond_to do |format| if @news.save format.html { redirect_to edit_category_news_path(@news.category, @news), notice: 'News was successfully created.' } format.json { render json: @news, status: :created, location: @news } else format.html { render action: "new", :category_id => @news.category, :id => @news } format.json { render json: @news.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /news/1 DELETE /news/1.json
79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/ems/news_controller.rb', line 79 def destroy @news = News.find(params[:id]) category = @news.category @news.destroy respond_to do |format| format.html { redirect_to category_news_index_path(category), notice: 'News was successfully deleted.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /news/1/edit
40 41 42 43 |
# File 'app/controllers/ems/news_controller.rb', line 40 def edit @news = News.find(params[:id]) @news.assets.build end |
#index ⇒ Object
GET /news GET /news.json
6 7 8 9 10 11 12 13 |
# File 'app/controllers/ems/news_controller.rb', line 6 def index @news = News.all respond_to do |format| format.html # index.html.erb format.json { render json: @news } end end |
#new ⇒ Object
GET /news/new GET /news/new.json
28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/ems/news_controller.rb', line 28 def new @news = News.new @news.assets.build @news.category = Category.find params[:category_id] respond_to do |format| format.html # new.html.erb format.json { render json: @news } end end |
#show ⇒ Object
GET /news/1 GET /news/1.json
17 18 19 20 21 22 23 24 |
# File 'app/controllers/ems/news_controller.rb', line 17 def show @news = News.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @news } end end |
#update ⇒ Object
PUT /news/1 PUT /news/1.json
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/ems/news_controller.rb', line 63 def update @news = News.find(params[:id]) respond_to do |format| if @news.update_attributes(params[:news]) format.html { redirect_to edit_category_news_path(@news.category, @news), notice: 'News was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit", :category_id => @news.category, :id => @news } format.json { render json: @news.errors, status: :unprocessable_entity } end end end |