#1082 ✓not-applicable
Robert Sköld

Calling first_or_create twice raises ArgumentError.

Reported by Robert Sköld | October 7th, 2009 @ 04:23 PM | in 0.10.2

When running the first_or_create twice, passing a setter which is only a setter of the model and not a property, the second time it raises an ArgumentError.

Probably because it then uses first instead of create i guess?

I posted a working example here (using 0.10.1): https://gist.github.com/8a151f39f7717a61984d

Considering that the first_or_create might often be in a loop I'd prefer not to having to rescue the ArgumentError

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) October 8th, 2009 @ 01:05 AM

    • Milestone set to 0.10.2
    • State changed from “new” to “accepted”
    • Assigned user set to “Dan Kubb (dkubb)”

    The weird thing is that this works at all.

    The first call to first_or_create should explode because there's no :eid property in User. You have an "eid=" method defined, but the finder, which would be executed first, doesn't take anything into account aside from the properties defined in the model.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) October 23rd, 2009 @ 02:03 AM

    • State changed from “accepted” to “not-applicable”

    I just tried the script with edge dm-core, and it explodes on the first call to first_or_create, which is what I would expect because it would first attempt to search with the options, and :eid is not a valid Property.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket