Hello,

I'm relatively new to DataMapper (just started using it with some Sinatra 
projects), and wanted to know if the following is possible:

class Business
  ...
  property :postal_code, String  # all are in the format "N1N 1N1", so 7 
characters in length

  belongs_to :postalcodes
end

class PostalCode
  ...
  property :postal_code, String, key: true  # all are in the format 
"N1N1N1", so 6 characters in length

  has n, :businesses # here I would like to tell it to associate to 
Business using self.postal_code and 
(Business.postal_code[0..2]+Business.postal_code[4..6]) or 
Business.postal_code.gsub(/\s/,"")
end

Is that possible, or should I just change all the postal codes in the 
Business model to match those in the PostalCode model's key (ie 6 
characters in length with no space)?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/datamapper/-/db1HRRzIvl4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to