Skip to content

Commit

Permalink
Allow primary_key to be set on create
Browse files Browse the repository at this point in the history
ActiveRecord allows the primary key to be set on create. This makes
ActiveRemote#create behave the same way by allowing the primary_key
attribute to be sent in a create operation.
  • Loading branch information
mattnichols authored and liveh2o committed Feb 26, 2018
1 parent 3a259ae commit 6acce3f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion lib/active_remote/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ def remote_create
run_callbacks :create do
# Use the getter here so we get the type casting.
new_attributes = attributes
new_attributes.delete(primary_key.to_s)

response = rpc.execute(:create, new_attributes)

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/active_remote/persistence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
subject { Tag.new }

it "creates the record" do
expected_attributes = subject.attributes.reject { |key, value| key == "guid" }
expected_attributes = subject.attributes
expect(rpc).to receive(:execute).with(:create, expected_attributes)
subject.save
end
Expand Down

0 comments on commit 6acce3f

Please sign in to comment.