From: Eric Davis Date: Tue, 21 Sep 2010 15:20:37 +0000 (+0000) Subject: Refactor: split NewsController#edit into #edit and #update X-Git-Tag: 1.1.0~345 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=01d1a02df425cf5afb1036e57f2d148059472786;p=redmine.git 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 --- 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') %>