diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index f4e4b655..5a1d36e0 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]) - flash[:notice] = l(:notice_successful_update) - redirect_to :action => 'show', :id => @news - end 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 04d64df1..da256031 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 c32c6843..851ef3f7 100644 --- a/app/views/news/show.rhtml +++ b/app/views/news/show.rhtml @@ -11,8 +11,8 @@ <% if authorize_for('news', 'edit') %>