add_salaries_to_all_projects.rb

add employees to existing projects - Christophe Benz, 2010-01-28 11:28

Download (536 Bytes)

 
1
#!/usr/bin/env /home/redmine/redmine/script/runner
2
field = UserCustomField.find_by_name('Employee')
3
employee_ids = field.custom_values.find_all_by_value('1').map { |o| o.customized_id }
4
Project.all.each do |project|
5
    employee_ids.each do |employee_id|
6
        project.members << Member.new(:user_id => employee_id,
7
                                      :project => project,
8
                                      :role => Role.find_by_name('Rapporteur'),
9
                                      :mail_notification => false)
10
    end
11
end