fixed bug when no version is selected in projects/add_file

git-svn-id: http://redmine.rubyforge.org/svn/trunk@97 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2006-12-16 16:31:11 +00:00
parent 005f4baaa4
commit bee3f353fc
3 changed files with 20 additions and 18 deletions
+8 -10
View File
@@ -340,16 +340,14 @@ class ProjectsController < ApplicationController
render :action => "list_news", :layout => false if request.xhr?
end
def add_file
if request.post?
# Save the attachment
if params[:attachment][:file].size > 0
@attachment = @project.versions.find(params[:version_id]).attachments.build(params[:attachment])
@attachment.author_id = self.logged_in_user.id if self.logged_in_user
if @attachment.save
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
end
def add_file
@attachment = Attachment.new(params[:attachment])
if request.post? and params[:attachment][:file].size > 0
@attachment.container = @project.versions.find_by_id(params[:version_id])
@attachment.author = logged_in_user
if @attachment.save
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
end
end
@versions = @project.versions