]> source.dussan.org Git - redmine.git/commitdiff
Preserve uploaded files when on news.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 23 Feb 2012 13:07:27 +0000 (13:07 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 23 Feb 2012 13:07:27 +0000 (13:07 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8942 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/news_controller.rb
app/views/news/_form.html.erb

index 3084976102afc0c6f6030c3d94f01711e9f2eca3..9d55f08b3d11626dd1a95646bd6756e024b16112 100644 (file)
@@ -69,6 +69,7 @@ class NewsController < ApplicationController
   def create
     @news = News.new(:project => @project, :author => User.current)
     @news.attributes = params[:news]
+    @news.save_attachments(params[:attachments])
     if @news.save
       attachments = Attachment.attach_files(@news, params[:attachments])
       render_attachment_warning_if_needed(@news)
@@ -83,6 +84,7 @@ class NewsController < ApplicationController
   end
 
   def update
+    @news.save_attachments(params[:attachments])
     if @news.update_attributes(params[:news])
       attachments = Attachment.attach_files(@news, params[:attachments])
       render_attachment_warning_if_needed(@news)
index 410df0e9920e5d84b093c74b5f5d2559be8a5336..a0d2167a93d3083070b0aee79c75e4729516ea77 100644 (file)
@@ -3,7 +3,7 @@
 <p><%= f.text_field :title, :required => true, :size => 60 %></p>
 <p><%= f.text_area :summary, :cols => 60, :rows => 2 %></p>
 <p><%= f.text_area :description, :required => true, :cols => 60, :rows => 15, :class => 'wiki-edit' %></p>
-<p id="attachments_form"><%= label_tag('attachments[1][file]', l(:label_attachment_plural))%><%= render :partial => 'attachments/form' %></p>
+<p id="attachments_form"><%= label_tag('attachments[1][file]', l(:label_attachment_plural))%><%= render :partial => 'attachments/form', :locals => {:container => @news} %></p>
 </div>
 
 <%= wikitoolbar_for 'news_description' %>