diff --git a/lib/virtus/instance_methods.rb b/lib/virtus/instance_methods.rb index 4448bf66..8472bcb8 100644 --- a/lib/virtus/instance_methods.rb +++ b/lib/virtus/instance_methods.rb @@ -70,6 +70,7 @@ def attributes def attributes=(attributes) attribute_set.set(self, attributes) end + alias_method :update_attributes, :attributes= end # MassAssignment diff --git a/spec/integration/mass_assignment_with_accessors_spec.rb b/spec/integration/mass_assignment_with_accessors_spec.rb index 72e1124e..488b633a 100644 --- a/spec/integration/mass_assignment_with_accessors_spec.rb +++ b/spec/integration/mass_assignment_with_accessors_spec.rb @@ -38,6 +38,12 @@ def _id=(value) expect(subject.subcategory).to eq('Furniture') end + specify 'can be updated with #update_attributes' do + subject.update_attributes({:categories => ['Home', 'Furniture']}) + expect(subject.category).to eq('Home') + expect(subject.subcategory).to eq('Furniture') + end + specify 'respects accessor visibility' do expect(subject.id).not_to eq(100) end