Legacy Primary Key

4 views
Skip to first unread message

Nielson Rolim

unread,
Feb 8, 2011, 4:01:42 PM2/8/11
to ObjectiveResource
Hi Guys,

I'm working with a legacy database and the primary key is not called
"id".

On the Rails web service, in my Product Model, I configured the new
primary key (set_primary_key :cod), but on the iPhone side I am not
being able to recover the remote id.

If I try [product getRemoteId]; it returns nil.

On my iPhone app, in my Product class, I tried to configure the
primary key as productId or cod, but neither productId nor cod worked.

Does anyone have any ideas?

David White

unread,
Feb 9, 2011, 2:54:07 AM2/9/11
to objectiv...@googlegroups.com
Hi Nielson,

I'm not sure about what getRemoteId does as I'm new to ObjectiveResource (I'm assuming it's just doing a request to http://localhost:3000/:controller/:id.xml) however seeing the request thats getting made by the Rails application in your development.log would be helpful and may explain why you're getting a nil object.

David

Nielson Rolim

unread,
Feb 9, 2011, 5:46:15 AM2/9/11
to objectiv...@googlegroups.com
I'm new in ObjectiveResource too... but looking in its source code I saw that getRemoteId returns the model object id and uses in methods like updateRemote and deleteRemote. Like it is returning nil for me, I was not being able to update or delete a record in my iPhone app.

Well, I didn't find a solution in ObjectiveResource... but I found an alternative solution that worked for me. I just created a new column in my database's table called "id" and created a TRIGGER to copy the value of the "cod" column before every INSERT.

As I said, it was an alternative solution and only worked for me because I had administrator privilegies in the database. But it would not work if I need to consume a third party Rails Web Service.

Is there any way to configure the primary key column name in ObjectiveResource?

--
You received this message because you are subscribed to the Google Groups "ObjectiveResource" group.
To post to this group, send email to objectiv...@googlegroups.com.
To unsubscribe from this group, send email to objectiveresou...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/objectiveresource?hl=en.



--
Nielson Rolim
nielso...@gmail.com
Reply all
Reply to author
Forward
0 new messages