[Streamlined][877] fixed bug in association. rb where invalid table key could potentially be used

0 views
Skip to first unread message

svn-str...@thinkrelevance.com

unread,
Jul 16, 2008, 2:14:25 PM7/16/08
to streamli...@googlegroups.com
Revision
877
Author
matthew
Date
2008-07-16 14:14:25 -0400 (Wed, 16 Jul 2008)

Log Message

fixed bug in association.rb where invalid table key could potentially be used

Modified Paths

Diff

Modified: edge/streamlined/lib/streamlined/column/association.rb (876 => 877)


--- edge/streamlined/lib/streamlined/column/association.rb	2008-07-16 13:37:15 UTC (rev 876)
+++ edge/streamlined/lib/streamlined/column/association.rb	2008-07-16 18:14:25 UTC (rev 877)
@@ -18,7 +18,7 @@
   attr_accessor :options_for_select
   attr_with_default :quick_add, 'true'
   delegates :name, :class_name, :to => :underlying_association
-  delegates :belongs_to?, :has_many?, :has_and_belongs_to_many?, :to => :underlying_association 
+  delegates :belongs_to?, :has_many?, :has_and_belongs_to_many?, :primary_key_name, :to => :underlying_association 
   
   def initialize(assoc, parent_model, edit, show)
     @underlying_association = assoc
@@ -130,7 +130,7 @@
       choices = options_for_select ? custom_options_for_select(view) : standard_options_for_select
       choices.unshift(unassigned_option) if column_can_be_unassigned?(parent_model, name)
       selected_choice = item.send(name).id if item.send(name)
-      result = view.select(model_underscore, name_as_id, choices, { :selected => selected_choice }, html_options)
+      result = view.select(model_underscore, primary_key_name, choices, { :selected => selected_choice }, html_options)
       result += render_quick_add(view) if should_render_quick_add?(view)
     end
     append_help(result)

Modified: edge/streamlined/test/unit/streamlined/column/association_test.rb (876 => 877)


--- edge/streamlined/test/unit/streamlined/column/association_test.rb	2008-07-16 13:37:15 UTC (rev 876)
+++ edge/streamlined/test/unit/streamlined/column/association_test.rb	2008-07-16 18:14:25 UTC (rev 877)
@@ -9,6 +9,7 @@
     @ar_assoc = flexmock(:name => 'some_name', :class_name => 'SomeClass')
     @model = flexmock(:name => 'model')
     @association = Association.new(@ar_assoc, @model, :inset_table, :count)
+    @association.stubs(:primary_key_name).returns("some_name_id")
   end
   
   # begin stub classes
Reply all
Reply to author
Forward
0 new messages