You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I have a "micro" twitter system I maintain, where we store profiles, tweets, favorites, and followers for users in our db.
We store them because we crunch a lot of data together and it's easier than calling the real twitter API every time.
I've noticed when trying to do a find_or_create_by on profiles that if I use the id for the profile it always attempts an update because of the ORM#new? method checking for an id.
I have a search that allows users to search for other Twitter users, and I then attempt to save the new twitter profile using the id, this ensures if a screen_name changes we still get who we were hoping for.
Any insight on the best way to handle this?
The text was updated successfully, but these errors were encountered:
Hi @sqlninja as you point out, this is a side effect of new? not knowing if the resource exists or not. The only workaround that comes to mind is calling save_existing when find or find_by returns nil. Let us know if that helps. Meanwhile I'm going to close this as a duplicate of #494.
So I have a "micro" twitter system I maintain, where we store profiles, tweets, favorites, and followers for users in our db.
We store them because we crunch a lot of data together and it's easier than calling the real twitter API every time.
I've noticed when trying to do a find_or_create_by on profiles that if I use the id for the profile it always attempts an update because of the ORM#new? method checking for an id.
I have a search that allows users to search for other Twitter users, and I then attempt to save the new twitter profile using the id, this ensures if a screen_name changes we still get who we were hoping for.
Any insight on the best way to handle this?
The text was updated successfully, but these errors were encountered: