I am making a website in rails with a lot of data. This data was writen by my client on an Excel file. But开发者_Go百科 i have a problem, how to manage foreign keys?
For example, I have many hotels on one sheet. Each hotel has a country, a continent, pictures... In my database a country is represented by its id but in excel, it's easier for the client to enter the name.
Anyone has a good solution to solve this problem?
I use rails 3.0.9 :)
Okay I think your client created a huge excel sheet and put all the data for one hotel in one line?! Thats right?
If thats the case I would suggest you to export the Data as a CSV file and write a parser that reads all the data from the csv file and Imports it in your Rails application. While parsing you can do the database normalization.
You can simply create a ruby script including your environment.rb so you have all the classes from your RoR Application.
provided the script is located in the main folder of your rails app,
include 'config/environment.rb'
精彩评论