From 01d1a02df425cf5afb1036e57f2d148059472786 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Tue, 21 Sep 2010 15:20:37 +0000 Subject: [PATCH] Refactor: split NewsController#edit into #edit and #update git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4168 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/news_controller.rb | 11 ++++++++--- app/views/news/edit.rhtml | 4 ++-- app/views/news/show.rhtml | 4 ++-- config/routes.rb | 2 +- lib/redmine.rb | 2 +- test/functional/news_controller_test.rb | 4 ++-- test/integration/routing_test.rb | 4 +++- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index f4e4b6559..5a1d36e0f 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -60,14 +60,19 @@ class NewsController < ApplicationController end end end - + def edit - if request.post? and @news.update_attributes(params[:news]) + end + + def update + if request.put? and @news.update_attributes(params[:news]) flash[:notice] = l(:notice_successful_update) redirect_to :action => 'show', :id => @news + else + render :action => 'edit' end end - + def add_comment @comment = Comment.new(params[:comment]) @comment.author = User.current diff --git a/app/views/news/edit.rhtml b/app/views/news/edit.rhtml index 04d64df1f..da256031d 100644 --- a/app/views/news/edit.rhtml +++ b/app/views/news/edit.rhtml @@ -1,7 +1,7 @@

<%=l(:label_news)%>

-<% labelled_tabular_form_for :news, @news, :url => { :action => "edit" }, - :html => { :id => 'news-form' } do |f| %> +<% labelled_tabular_form_for :news, @news, :url => { :action => "update" }, + :html => { :id => 'news-form', :method => :put } do |f| %> <%= render :partial => 'form', :locals => { :f => f } %> <%= submit_tag l(:button_save) %> <%= link_to_remote l(:label_preview), diff --git a/app/views/news/show.rhtml b/app/views/news/show.rhtml index c32c6843e..851ef3f75 100644 --- a/app/views/news/show.rhtml +++ b/app/views/news/show.rhtml @@ -11,8 +11,8 @@ <% if authorize_for('news', 'edit') %>