Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #55 from jmonteiro/classify_vs_camelize

I want to be able to have ActiveHash classes ending with an 's' (such as 'SchoolStatus')
  • Loading branch information...
commit 43aff07f53fca40c25ea92a9cca1f740d8ac1d3f 2 parents 7d1f6ae + 451ae23
@zilkey authored
View
2  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)
View
10 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
Please sign in to comment.
Something went wrong with that request. Please try again.