#774 ✓resolved
hinzing

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

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.

New-ticket Create new ticket

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

Pages