Defect #24
closedSVN Repository attributes aren't saved if modified after creation
0%
Description
If one changes the SVN repository path after one has created and set it already, the path is not updated. This seems
to be because of this bit in projects_controller.rb:
if params[:repository_enabled]
case params[:repository_enabled]
when "0"
@project.repository = nil
when "1"
@project.repository ||= Repository.new
@project.repository.attributes = params[:repository]
end
end
This seems to be fixed in trunk, but the fix is:
if params[:repository_enabled] && params[:repository_enabled] == "1"
@project.repository = Repository.new
@project.repository.attributes = params[:repository]
end
Which would generate a new Repository every time a modification was made. It seems like a better solution would be:
if params[:repository_enabled]
case params[:repository_enabled]
when "0"
@project.repository = nil
when "1"
@project.repository ||= Repository.new
@project.repository.update_attributes params[:repository] # use update_attributes
end
end
If the update were to fail, then the save of the project would also fail due to the validate_associated validation in
the Project model. Otherwise, whether it was or was not a new Repository, it would update the attributes and save, and
only generate a new Repository once, when there was no previous one to update.
A similar solution would probably work for the wiki.
Updated by Jean-Philippe Lang almost 18 years ago
As you it's fixed in the repository.
This code is what there is in trunk, but for the ADD action (that
means called when you CREATE a project, so a new repository has
to be created):
if params[:repository_enabled] && params[:repository_enabled]
== "1"
@project.repository = Repository.new
@project.repository.attributes = params[:repository]
end
The last code you "propose" is exactly what there is
in the trunk but in the EDIT method of the projects controller.
Updated by Antonio Salazar almost 18 years ago
There's me not paying enough attention to the code late at
night :-) Sorry!