Permalink
Browse files

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

… be used
  • Loading branch information...
1 parent a540467 commit 481b03556c0b9e4f1014b7ab77d050758591b558 matthew committed Jul 16, 2008
Showing with 3 additions and 2 deletions.
  1. +2 −2 lib/streamlined/column/association.rb
  2. +1 −0 test/unit/streamlined/column/association_test.rb
@@ -18,7 +18,7 @@ class Streamlined::Column::Association < Streamlined::Column::Base
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 @@ def render_td_edit(view, item)
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)
@@ -9,6 +9,7 @@ def setup
@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

0 comments on commit 481b035

Please sign in to comment.