diff --git a/lib/associations/associations.rb b/lib/associations/associations.rb index eacaacc9..34dd341a 100644 --- a/lib/associations/associations.rb +++ b/lib/associations/associations.rb @@ -5,7 +5,7 @@ module ActiveRecordExtensions def belongs_to_active_hash(association_id, options = {}) options = { - :class_name => association_id.to_s.classify, + :class_name => association_id.to_s.camelize, :foreign_key => association_id.to_s.foreign_key }.merge(options) diff --git a/spec/associations/associations_spec.rb b/spec/associations/associations_spec.rb index d637aa32..65775f7e 100644 --- a/spec/associations/associations_spec.rb +++ b/spec/associations/associations_spec.rb @@ -26,6 +26,9 @@ class Author < ActiveHash::Base include ActiveHash::Associations end + class SchoolStatus < ActiveHash::Base + end + class Book < ActiveRecord::Base establish_connection :adapter => "sqlite3", :database => ":memory:" connection.create_table(:books, :force => true) do |t| @@ -133,6 +136,13 @@ class Book < ActiveRecord::Base association.should_not be_nil association.klass.name.should == City.name end + + it "handles classes ending with an 's'" do + School.belongs_to_active_hash :school_status + association = School.reflect_on_association(:school_status) + association.should_not be_nil + association.klass.name.should == SchoolStatus.name + end end end