To create a new table, start by selecting a Rails application. Then either choose Create New Rails Table from the Application menu or click on the + symbol in the upper right hand corner of the list of tables.
The New Table dialog allows you to set up the fields to be included in the new table. To add fields simply type them into the box at the top of the dialog and press Return or Enter.
Once fields have been added you can click in the Type column to choose the field data types with a pop-up menu.
If you decide you don't want a field after all simply click on the minus button to the left of the field name. You can change a field name by double clicking on the name, and you can also drag to re-arrange the order of the fields.
Before you can actually create the table you must specify the table name. Keep in mind that Rails will "pluralize" the name you specify. For example, name will become names, product will become products, person will become people, etc. You should always specify the singular form of the table name you want.
The scaffold option tells Rails to automatically generate Ruby code for a standard web application. You'll usually want to leave this option checked.
Press the Create Table button to actually create the table. After a short delay, Track Magic will display the shell output from the command used to create the table.
The new table will also appear in the list of tables in the Track Magic window.
Note: If you've checked the When creating a new table, auto create synchronized Panorama database option (in the Preferences dialog) Track Magic will automatically create a new Panorama database for displaying and editing the data in your new Rails table. See Preferences for more information.
Creating a New Rails Table from a Panorama Database (Cloning)
So far we’ve assumed that you are creating your new table from scratch. However, you can also create a Rails table from an existing Panorama database. Track Magic will use the Panorama database as a template for creating the new Rails table, and it can even automatically transfer the data from the Panorama database into the new Rails table. (If you don't have a Panorama database but do have a text file containing the data, it’s very easy to create a Panorama database — see the next section for details.)
Start by opening the Panorama database you want to clone. Make sure that the fields you want to include in the Rails table have the names and data types you want to use (double click on the field names to change the name and type, if necessary). It’s ok if the database has additional fields you don’t want to include in the Rails table, those can be eliminated later.
Now open the New Table dialog (Application menu), just as you did when creating a table from scratch. When this dialog is open a new Clone menu appears. This menu lists any Panorama databases that are currently open — choose the database that you want to clone.
Track Magic will automatically fill in the field names and data types from the cloned Panorama database. If there are any fields you don't want to include, remove them now (by clicking on the - button). You can drag to rearrange the fields, but you should not change the field names.
Enter the singular name for the table, then press the Create Table button. Track Magic will create the new table.
The final step is to upload the data from the original Panorama database. To do that you’ll need to create a synchronized local copy of the Rails table (see Creating a Rails Synchronized Panorama Database). You can do that either using the Create Local Synchronized Database command in the Table menu, or by clicking the + button next to the new table’s name.
Track Magic will ask you to confirm that you want to transfer the data from the original Panorama database.
When you press Yes, Track Magic creates the new local Panorama database, copies the data into it, then uploads the data into the Rails table.
The new Rails table is now ready to use, either thru the local Panorama database (see Working with Data) or with the normal Rails web interface.
Creating a New Rails Table from a Tab or Comma Delimited Text File
If you use Track Magic, but not Panorama, you probably don’t have Panorama databases ready to be transferred to Rails. However, you may have tab or comma delimited text files that you want to transfer to Rails (for example, perhaps you have exported a spreadsheet from Excel or Numbers, or a database from FileMaker or some other database application). It's easy to convert a text file into a Panorama database. You can then convert the Panorama database into a Rails table using the steps described in the previous section. It all starts with a tab or comma delimited text file, like this.
In Track Magic, choose New File from the File menu. Then drag the text file from the Finder onto the left hand side of the New Database wizard.
The wizard will display the contents of the first line of the text file in the left side of the window (under Fields).
If the first line of the text file happened to contain the field names then you are ready to go. Otherwise, you'll need to edit the text, replacing the actual data with the field names you want to use. In the illustration below five field names have been entered, with three to go.
Once all of the field names are set up, press the Make New Database button. The wizard will create a new Panorama database with the data from the text file.
The final step is to save the new database and give it a name. Once that is done you can easily convert it into a Rails table (see the previous section).