primary key in hm/bt assoc for collection_selects
Reported by hinzing | August 4th, 2010 @ 06:45 PM | in Hobo 1.3 (Rails 3)
Hi,
first day trying hobo, very nice. But I ran into a problem using a primary key for a hm/bt association. In the collection_select this is not realised and the value is still the id of the parent.
I did a small hack, sorry for not using git - fork, but I'm not used to it.
in hobo/taglibs/rapid_forms.dryml:
instead of (line 664 to 671):
if text_method.nil? select_options = options.map { |x| [x.to_s, x.id] } else select_options = options.map do |x| [ text_method.split(".").inject(x) { |v, method| v.send(method) }, x.id ] end end
do the following:
if text_method.nil? select_options = options.map { |x| [x.to_s, x.send(this_field_reflection.options[:primary_key] || :id )] } else select_options = options.map do |x| [ text_method.split(".").inject(x) { |v, method| v.send(method) }, x.send(this_field_reflection.options[:primary_key] || :id ) ] end end
Best,
Martin.
Comments and changes to this ticket
-
Matt Jones September 15th, 2011 @ 06:19 PM
- State changed from new to open
- Milestone set to Hobo 1.3 (Rails 3)
- Milestone order changed from 197867 to 0
-
Matt Jones September 20th, 2011 @ 04:51 PM
(from [83e96e17b388e562d89c0c3fd54cd76f5e7656e0]) [#774] respect :primary_key option in select-one and friends https://github.com/tablatom/hobo/commit/83e96e17b388e562d89c0c3fd54...
-
Matt Jones September 20th, 2011 @ 04:52 PM
- State changed from open to resolved
There were a couple of additional spots where this needed to be fixed (for instance, in the
belongs_to_with_test_methods
code).This should work correctly now.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
People watching this ticket
Referenced by
- 774 primary key in hm/bt assoc for collection_selects (from [83e96e17b388e562d89c0c3fd54cd76f5e7656e0]) [#774] ...