Reputation: 558
I am using a Rails webservice to mediate between an iOS app and a legacy SQL Server database.
Using Active Record and a slew of ruby gems I have managed to generate a set of models which map directly to the SQL database.
However, the objects in my application depend not on any single one of the aforementioned models, but consist of data represented by several models at once (the SQL tables utilize foreign keys).
The question is: what is the best way to map (into Core Data) between my app and the ruby models?
I was thinking it would make sense to generate 'intermediate' models which correspond directly to my app's objects, and which consist of many 'belongs_to' statements to these existing models. Is this the purpose of belongs_to? Is there a better way? Am I even understanding the capabilities of Rails or am I making things too simplistic or complex?
Thanks in advance!!
EDIT: For example,
I have a Core Data Entity 'Game Instance' which consists of the following attributes:
- name
- denom
- lines
- credits
- reels
- type
- sectionCode
- positionCode
The pertinent SQL tables / Rails models are as follows:
'GameInstance'
- GameID (FK)
- LocationID (FK)
'GameConfiguration'
- GameID
- MachineID (FK)
- DenomID (FK)
- Lines
- Credits
- Reels
'Game'
- MachineID
- Type
- Name
'Denom'
- DenomID
- DenomValue
'Location'
- LocationID
- SectionID (FK)
- PositionID (FK)
'Section'
- SectionID
- SectionCode
'Position'
- PositionID
- PositionCode
As you can see, this single Core Data entity would be dependent on several of the Ruby models.
Upvotes: 0
Views: 210
Reputation: 11
You would probably have an easier time not using RestKit, and setting up the app to work with what you already have, not what you want. Network connections are pretty trivial on iOS, especially with fantastic block-based libraries such as AFNetworking. That will be the path of least resistance.
Upvotes: 1