Hello rails friends,
I am writing a soap interface to a databse for a .Net guy in rails.
Actionwebservice kicks ass, however, I need some help translating the
object model to a relational one:
class Customer{
string firstName
#blah
string[] email_addresses
PurchaseHistory[] myPurchases
}
class PurchaseHistory{
#blah blah blah
}
The object model is non-negotiable. I am not allowed to change it, I
have to create
equivalent soap objects for his types.
The problem comes with the arrays. How do I store those in the
database?
Here is the migration I’ve wrote so far:
class CreateCustomers < ActiveRecord::Migration
def self.up
create_table :customers do |t|
t.column :firstName, :string
#blah
t.column : email_addresses, [:string] # This does not work.
Migrate freaks out! help!
# purchase history array??? help!
end
end
def self.down
drop_table :customers
end
Migrate says this when i try to migrate that:
== CreateCustomers: migrating
– create_table(:customers)
rake aborted!
undefined method `to_sym’ for [:string]:Array
So my questions are:
- What is the proper way to do this?
=>How do I store an array in the database?
=>How do I tell activerecord to create a column for an array?
Please do not reply “your object model is poor” because that is out of
my control.
Thank you for your time and your help! I really appreciate the ROR
community and the time they take promoting their framework. I guess when
you help a noob like me, then eventually I get good at ROR and will be
able reach out eventually and help other noobs.