Skip to content

Commit

Permalink
Merge pull request #16 from appfolio/UpdateReadmeAndAppraisals
Browse files Browse the repository at this point in the history
update README and appraisals
  • Loading branch information
jonkessler committed Aug 2, 2015
2 parents 39c3e28 + 710e94b commit 85dec6b
Show file tree
Hide file tree
Showing 89 changed files with 243 additions and 224 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ gemfile:
- gemfiles/rails_3.2.19.gemfile
- gemfiles/rails_3.2.20.gemfile
- gemfiles/rails_3.2.21.gemfile
- gemfiles/rails_3.2.22.gemfile
- gemfiles/rails_4.0.0.gemfile
- gemfiles/rails_4.0.1.gemfile
- gemfiles/rails_4.0.2.gemfile
Expand All @@ -80,8 +81,12 @@ gemfile:
- gemfiles/rails_4.1.7.1.gemfile
- gemfiles/rails_4.1.8.gemfile
- gemfiles/rails_4.1.9.gemfile
- gemfiles/rails_4.1.10.gemfile
- gemfiles/rails_4.1.11.gemfile
- gemfiles/rails_4.1.12.gemfile
- gemfiles/rails_4.2.0.gemfile
- gemfiles/rails_4.2.1.gemfile
- gemfiles/rails_4.2.2.gemfile
- gemfiles/rails_4.2.3.gemfile

sudo: false
180 changes: 88 additions & 92 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,100 +1,96 @@
RAILS_VERSIONS = [
"3.0.5",
"3.0.6",
"3.0.7",
"3.0.8",
"3.0.9",
"3.0.10",
"3.0.11",
"3.0.12",
"3.0.13",
"3.0.14",
"3.0.15",
"3.0.16",
"3.0.17",
"3.0.18",
"3.0.19",
"3.0.20",
"3.1.0",
"3.1.2",
"3.1.3",
"3.1.4",
"3.1.5",
"3.1.6",
"3.1.7",
"3.1.8",
"3.1.9",
"3.1.10",
"3.1.11",
"3.1.12",
"3.2.0",
"3.2.1",
"3.2.2",
"3.2.3",
"3.2.4",
"3.2.5",
"3.2.6",
"3.2.7",
"3.2.8",
"3.2.9",
"3.2.10",
"3.2.11",
"3.2.12",
"3.2.13",
"3.2.14",
"3.2.15",
"3.2.16",
"3.2.17",
"3.2.18",
"3.2.19",
"3.2.20",
"3.2.21",
"4.0.0",
"4.0.1",
"4.0.2",
"4.0.3",
"4.0.4",
"4.0.5",
"4.0.6",
"4.0.7",
"4.0.8",
"4.0.9",
"4.0.10",
"4.0.11",
"4.0.11.1",
"4.0.12",
"4.0.13",
"4.1.0",
"4.1.1",
"4.1.2",
"4.1.3",
"4.1.4",
"4.1.5",
"4.1.6",
"4.1.7",
"4.1.7.1",
"4.1.8",
"4.1.9",
"4.2.0",
"4.2.1",
"4.2.3"
]
RAILS_VERSIONS = %w(
3.0.5
3.0.6
3.0.7
3.0.8
3.0.9
3.0.10
3.0.11
3.0.12
3.0.13
3.0.14
3.0.15
3.0.16
3.0.17
3.0.18
3.0.19
3.0.20
3.1.0
3.1.2
3.1.3
3.1.4
3.1.5
3.1.6
3.1.7
3.1.8
3.1.9
3.1.10
3.1.11
3.1.12
3.2.0
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.2.6
3.2.7
3.2.8
3.2.9
3.2.10
3.2.11
3.2.12
3.2.13
3.2.14
3.2.15
3.2.16
3.2.17
3.2.18
3.2.19
3.2.20
3.2.21
3.2.22
4.0.0
4.0.1
4.0.2
4.0.3
4.0.4
4.0.5
4.0.6
4.0.7
4.0.8
4.0.9
4.0.10
4.0.11
4.0.11.1
4.0.12
4.0.13
4.1.0
4.1.1
4.1.2
4.1.3
4.1.4
4.1.5
4.1.6
4.1.7
4.1.7.1
4.1.8
4.1.9
4.1.10
4.1.11
4.1.12
4.2.0
4.2.1
4.2.2
4.2.3
)

RAILS_VERSIONS.each do |version|
appraise "rails_#{version}" do
gem 'activerecord', version

minitest_version = case version
when /^3/
'~> 4.0'
when /^4.0/
'~> 4.2'
when /^4.[12]/
'~> 5.1'
else
raise 'no minitest version specified for that ActiveRecord version'
if version =~ /^3/
gem 'minitest', '~> 4.0'
end

gem 'minitest', minitest_version
end
end
54 changes: 32 additions & 22 deletions README.rdoc → README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
== Description
[![Build Status](https://travis-ci.org/appfolio/store_base_sti_class.svg?branch=master)](https://travis-ci.org/appfolio/store_base_sti_class)
## Description

Given the following class definitions,

class Address
belongs_to :addressable, :polymorphic => true
end
```ruby
class Address
belongs_to :addressable, :polymorphic => true
end

class Person
has_many :addresses, :as => addressable
end
class Person
has_many :addresses, :as => addressable
end

class Vendor < Person
end
class Vendor < Person
end
```

and given the following code,

vendor = Vendor.create(...)
address = vendor.addresses.create(...)
```ruby
vendor = Vendor.create(...)
address = vendor.addresses.create(...)

p vendor
p address
p vendor
p address
```

will output,

#<Vendor id: 1, type: "Vendor" ...>
#<Address id: 1, addressable_id: 1, addressable_type: 'Person' ...>
```ruby
#<Vendor id: 1, type: "Vendor" ...>
#<Address id: 1, addressable_id: 1, addressable_type: 'Person' ...>
```

Notice that addressable_type column is Person even though the actual class is Vendor.

Expand All @@ -34,34 +41,37 @@ a join with persons or an extra query is required to find out the actual type of
This gem add ActiveRecord::Base.store_base_sti_class configuration option. It defaults to true for backwards compatibility. Setting it false will alter ActiveRecord's behavior to store the actual class in polymorphic _type columns when STI is used.

In the example above, if the ActiveRecord::Base.store_base_sti_class is false, the output will be,

```
#<Vendor id: 1, type: "Vendor" ...>
#<Address id: 1, addressable_id: 1, addressable_type: 'Vendor' ...>
```

== Usage
## Usage

Add the following line to your Gemfile,

gem 'store_base_sti_class'
```ruby
gem 'store_base_sti_class'
```

then bundle install. Once you have the gem installed, add the following to one of the initializers (or make a new one) in config/initializers,

ActiveRecord::Base.store_base_sti_class = false

When changing this behavior you will have write a migration to update all of your existing _type columns accordingly. You may also need to change your application if it explicitly relies on the _type columns.

== Notes
## Notes

This gem incorporates work from:
- https://github.com/pkmiec/store_base_sti_class_for_3_0
- https://github.com/appfolio/store_base_sti_class_for_3_1
- https://github.com/Lovethis/store_base_sti_class_for_3_1
- https://github.com/codepodu/store_base_sti_class_for_4_0

It currently works with ActiveRecord 3.0.5 through 4.0.1.
It currently works with ActiveRecord 3.0.5 through 4.2.x.

== Copyright
## Copyright

Copyright (c) 2011 AppFolio, inc. See LICENSE.txt for
Copyright (c) 2011-2015 AppFolio, inc. See LICENSE.txt for
further details.

1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'rubygems'
require 'bundler'

require 'appraisal'

begin
Bundler.setup(:default, :development)
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.10.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.10"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.11.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.11"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.12.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.12"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.13.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.13"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.14.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.14"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.15.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.15"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.16.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.16"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.17.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.17"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.18.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.18"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.19.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.19"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.20.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.20"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.0.5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "activerecord", "3.0.5"
gem "minitest", "~> 4.0"

gemspec :path => "../"
gemspec :path=>"../"
Loading

0 comments on commit 85dec6b

Please sign in to comment.