@@ -29,7 +29,8 class CustomFieldEnumerationsController < ApplicationController | |||
|
29 | 29 | end |
|
30 | 30 | |
|
31 | 31 | def create |
|
32 |
@value = @custom_field.enumerations.build |
|
|
32 | @value = @custom_field.enumerations.build | |
|
33 | @value.safe_attributes = params[:custom_field_enumeration] | |
|
33 | 34 | @value.save |
|
34 | 35 | respond_to do |format| |
|
35 | 36 | format.html { redirect_to custom_field_enumerations_path(@custom_field) } |
@@ -38,7 +39,10 class CustomFieldEnumerationsController < ApplicationController | |||
|
38 | 39 | end |
|
39 | 40 | |
|
40 | 41 | def update_each |
|
41 |
|
|
|
42 | saved = CustomFieldEnumeration.update_each(@custom_field, params[:custom_field_enumerations]) do |enumeration, enumeration_attributes| | |
|
43 | enumeration.safe_attributes = enumeration_attributes | |
|
44 | end | |
|
45 | if saved | |
|
42 | 46 | flash[:notice] = l(:notice_successful_update) |
|
43 | 47 | end |
|
44 | 48 | redirect_to :action => 'index' |
@@ -16,6 +16,8 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class CustomFieldEnumeration < ActiveRecord::Base |
|
19 | include Redmine::SafeAttributes | |
|
20 | ||
|
19 | 21 | belongs_to :custom_field |
|
20 | 22 | attr_accessible :name, :active, :position |
|
21 | 23 | |
@@ -26,6 +28,10 class CustomFieldEnumeration < ActiveRecord::Base | |||
|
26 | 28 | |
|
27 | 29 | scope :active, lambda { where(:active => true) } |
|
28 | 30 | |
|
31 | safe_attributes 'name', | |
|
32 | 'active', | |
|
33 | 'position' | |
|
34 | ||
|
29 | 35 | def to_s |
|
30 | 36 | name.to_s |
|
31 | 37 | end |
@@ -56,7 +62,11 class CustomFieldEnumeration < ActiveRecord::Base | |||
|
56 | 62 | attributes.each do |enumeration_id, enumeration_attributes| |
|
57 | 63 | enumeration = custom_field.enumerations.find_by_id(enumeration_id) |
|
58 | 64 | if enumeration |
|
59 | enumeration.attributes = enumeration_attributes | |
|
65 | if block_given? | |
|
66 | yield enumeration, enumeration_attributes | |
|
67 | else | |
|
68 | enumeration.attributes = enumeration_attributes | |
|
69 | end | |
|
60 | 70 | unless enumeration.save |
|
61 | 71 | raise ActiveRecord::Rollback |
|
62 | 72 | end |
General Comments 0
You need to be logged in to leave comments.
Login now