From: Eric Davis Date: Mon, 20 Sep 2010 15:13:48 +0000 (+0000) Subject: Refactor: split NewsController#new into #new and #create methods. X-Git-Tag: 1.1.0~350 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3bc29e29e091b56bcffeb07ffb9c37c328525f99;p=redmine.git 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 --- 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 diff --git a/app/views/news/index.rhtml b/app/views/news/index.rhtml index 41e8bb355..2b53b7f72 100644 --- a/app/views/news/index.rhtml +++ b/app/views/news/index.rhtml @@ -7,7 +7,7 @@