Re: [DataMapper] One last call for help. Problem creating record with association...

2013-02-23 Thread kristian
@Chris

this manual property + setting it is a key did not work with me due to
some validations errors

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to datamapper+unsubscr...@googlegroups.com.
To post to this group, send email to datamapper@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [DataMapper] One last call for help. Problem creating record with association...

2013-02-23 Thread Chris Corbyn
You can also do:

property :province_name_short, String, field: "province"

belongs_to :province

Since :name_short is the key on Province, the mapping should work, as it will 
look for :province_name_short in Municipality.


Il giorno 24/feb/2013, alle ore 16:07, kristian  ha scritto:

> just add the key to the model
> 
>  belongs_to :province, 'Province', key: true
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "DataMapper" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to datamapper+unsubscr...@googlegroups.com.
> To post to this group, send email to datamapper@googlegroups.com.
> Visit this group at http://groups.google.com/group/datamapper?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to datamapper+unsubscr...@googlegroups.com.
To post to this group, send email to datamapper@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [DataMapper] One last call for help. Problem creating record with association...

2013-02-23 Thread kristian
just add the key to the model

  belongs_to :province, 'Province', key: true

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to datamapper+unsubscr...@googlegroups.com.
To post to this group, send email to datamapper@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [DataMapper] One last call for help. Problem creating record with association...

2013-02-23 Thread Gus Shotz
Oh, so maybe if I just renamed the :province property to something like 
:prov? I'll give it a try...

On Sunday, 24 February 2013 00:02:51 UTC-5, kristian wrote:
>
> I see, I just removed a key :( 
>
> well the point for me was that you can NOT have a property and a 
> association having the same name (not clear which one wins and when). 
>
> these belongs_to relations to create a property holding the 
> back_ref_key which can be declared manually as well. let me see if I 
> can get it for you . . . . 
>

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to datamapper+unsubscr...@googlegroups.com.
To post to this group, send email to datamapper@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [DataMapper] One last call for help. Problem creating record with association...

2013-02-23 Thread kristian
I see, I just removed a key :(

well the point for me was that you can NOT have a property and a
association having the same name (not clear which one wins and when).

these belongs_to relations to create a property holding the
back_ref_key which can be declared manually as well. let me see if I
can get it for you . . . .

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to datamapper+unsubscr...@googlegroups.com.
To post to this group, send email to datamapper@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [DataMapper] One last call for help. Problem creating record with association...

2013-02-23 Thread Gus Shotz

Thanks for the reply @kristian, unfortunately your solution requires the 
removal of one of the models keys which alters it from the desired schema 
(a composite key of Province and Municipality, which would not allow 
duplicate Municipality names in one Province, but would allow duplicate 
Municipality names in different Provinces). To verify this I just tried 
entering two entries for different Provinces, but with the same 
Municipality name, and I received a DataObjects::IntegrityError due to the 
:name key conflict.

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to datamapper+unsubscr...@googlegroups.com.
To post to this group, send email to datamapper@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [DataMapper] One last call for help. Problem creating record with association...

2013-02-23 Thread kristian
that are the modified models which works for me

class Province
  include DataMapper::Resource

  property :name_short, String, key: true, length: 2, unique: true
  property :name_long,  String, length: 1..50

  has n, :municipalities, 'Municipality'#,
  #  parent_key: [:name_short],
  #  child_key: [:province]
end

class Municipality
  include DataMapper::Resource

#  property :province,String, key: true, length: 2
  property :name,String, key: true, length: 1..40
  property :lat, Float
  property :long,Float

  property :current_population,  Integer

  belongs_to :province, 'Province'#,
#parent_key: [:name_short],
 #   child_key: [:province]

end

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to datamapper+unsubscr...@googlegroups.com.
To post to this group, send email to datamapper@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.