Vote #80506
未完了Add Project.find_by_name to target_project
0%
説明
Consider issue #6694, fix is trivial. Think about all those reporters who struggle to memorizing all that ID stuff.
File app/models/mail_handler.rb
Line 410
target = get_project_from_receiver_addresses
target ||= Project.find_by_identifier(get_keyword(:project))
target ||= Project.find_by_name(get_keyword(:project)) # just one new line
journals
--------------------------------------------------------------------------------
Since project names may not be unique, I think we cannot add the suggested code.
--------------------------------------------------------------------------------
Well, it's a good point. But then we have two options:
1. Mark Project.find_by_name as a deprecated/potentially-dangerous method and eliminate it in future versions of RM "Since project names may not be unique".
2. Implement some system-wide option "Enforce unique project names" and if it's disabled (users may create projects with non-unique names) then find_by_name method should throw an exception telling something like this: "Either you force unique names at settings page of your project or don't use Project.find_by_name in your code"
By the way,
@root@sd-srv-redmine-01:/opt/redmine/app# grep -r find_by_name
helpers/application_helper.rb: link_project = Project.find_by_identifier(identifier) || Project.find_by_name(identifier)
models/wiki.rb: project = Project.find_by_identifier(project_identifier) || Project.find_by_name(project_identifier)@
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
related_issues
relates,Closed,630,Allow non-unique names for projects
duplicates,Closed,6694,Bug in project name when create issue by email