Commit ff03e98b152a7f66f090779a36b44f459671dd8d

Authored by Dan Croak
1 parent cd305024

SF update

Showing 1 changed file with 4 additions and 2 deletions   Show diff stats
vendor/plugins/semi_formal/lib/semi_formal.rb
@@ -47,15 +47,17 @@ class SemiFormal < ActionView::Helpers::FormBuilder @@ -47,15 +47,17 @@ class SemiFormal < ActionView::Helpers::FormBuilder
47 # returns a drop-down with value of User#id, text of User#to_s 47 # returns a drop-down with value of User#id, text of User#to_s
48 # includes blank 48 # includes blank
49 # 49 #
50 - def belongs_to(field, *args) 50 + def belongs_to(association, *args)
51 options = args.extract_options! 51 options = args.extract_options!
52 52
53 - reflection = @object.class.reflect_on_association(field) 53 + reflection = @object.class.reflect_on_association(association)
54 collection = reflection.klass.all.collect {|each| [each.to_s, each.id] } 54 collection = reflection.klass.all.collect {|each| [each.to_s, each.id] }
55 55
56 options[:select] ||= {} 56 options[:select] ||= {}
57 options[:select][:include_blank] = true 57 options[:select][:include_blank] = true
58 58
  59 + field = "#{association}_id"
  60 +
59 "<div class=\"belongs_to\">" + 61 "<div class=\"belongs_to\">" +
60 label(field, options[:label] || {}) + 62 label(field, options[:label] || {}) +
61 select(field, collection, options[:select] || {}) + 63 select(field, collection, options[:select] || {}) +