summaryrefslogtreecommitdiffstats
path: root/app/controllers/news_controller.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-20 15:13:48 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-20 15:13:48 +0000
commit3bc29e29e091b56bcffeb07ffb9c37c328525f99 (patch)
treec10fba5f35f636f74683aac8ee0d2840b2a17308 /app/controllers/news_controller.rb
parent1a4f5e87f2839fa2260deefd4d9a5c992ef860fe (diff)
downloadredmine-3bc29e29e091b56bcffeb07ffb9c37c328525f99.tar.gz
redmine-3bc29e29e091b56bcffeb07ffb9c37c328525f99.zip
Refactor: split NewsController#new into #new and #create methods.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4163 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/news_controller.rb')
-rw-r--r--app/controllers/news_controller.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 4d44158a4..f4e4b6559 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -18,9 +18,9 @@
class NewsController < ApplicationController
default_search_scope :news
model_object News
- before_filter :find_model_object, :except => [:new, :index, :preview]
- before_filter :find_project_from_association, :except => [:new, :index, :preview]
- before_filter :find_project, :only => [:new, :preview]
+ before_filter :find_model_object, :except => [:new, :create, :index, :preview]
+ before_filter :find_project_from_association, :except => [:new, :create, :index, :preview]
+ before_filter :find_project, :only => [:new, :create, :preview]
before_filter :authorize, :except => [:index, :preview]
before_filter :find_optional_project, :only => :index
accept_key_auth :index
@@ -46,11 +46,17 @@ class NewsController < ApplicationController
def new
@news = News.new(:project => @project, :author => User.current)
+ end
+
+ def create
+ @news = News.new(:project => @project, :author => User.current)
if request.post?
@news.attributes = params[:news]
if @news.save
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'news', :action => 'index', :project_id => @project
+ else
+ render :action => 'new'
end
end
end