summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-21 15:20:37 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-21 15:20:37 +0000
commit01d1a02df425cf5afb1036e57f2d148059472786 (patch)
treeb6f75447b0227a5871a8fd7d633fbefa9953b318 /app
parent51359704a0a4a4af49fa8724059bc292649bb1da (diff)
downloadredmine-01d1a02df425cf5afb1036e57f2d148059472786.tar.gz
redmine-01d1a02df425cf5afb1036e57f2d148059472786.zip
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
Diffstat (limited to 'app')
-rw-r--r--app/controllers/news_controller.rb11
-rw-r--r--app/views/news/edit.rhtml4
-rw-r--r--app/views/news/show.rhtml4
3 files changed, 12 insertions, 7 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 @@
<h2><%=l(:label_news)%></h2>
-<% 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') %>
<div id="edit-news" style="display:none;">
-<% labelled_tabular_form_for :news, @news, :url => { :action => "edit", :id => @news },
- :html => { :id => 'news-form' } do |f| %>
+<% labelled_tabular_form_for :news, @news, :url => { :action => "update", :id => @news },
+ :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),