Also skips Rails 4.1 tests against Ruby 2.4.2 and ruby-head,
because Rails 4.2.8 is the first version of the 4.x series that
officially support Ruby 2.4.
* Loosen pry, pry-byebug depencency
```
Resolving dependencies...
byebug-9.1.0 requires ruby version >= 2.2.0, which is
incompatible with the current version, ruby 2.1.10p492
```
* Adjust nokogiri version constraint for CI
Update appveyor Ruby to 2.3 to work around:
```
Gem::InstallError: nokogiri requires Ruby version < 2.5, >= 2.2.
An error occurred while installing nokogiri (1.8.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.8.0'` succeeds before bundling.
```
and not 2.4 since:
https://ci.appveyor.com/project/bf4/active-model-serializers/build/1.0.1052-fix_ci/job/0q3itabsnvnxr83u
```
nokogiri-1.6.8.1-x86-mingw32 requires ruby version < 2.4, which is incompatible with the current version, ruby 2.4.1p111
```
* Include rails gem in Gemfile
(For Rails5)
In Rails5, checking for Rails::Railtie is better
* Rails5 test env requires Rails.application.class.name
rails-42d09f6b49da/railties/lib/rails/application.rb
```ruby
def secret_key_base
if Rails.env.test? || Rails.env.development?
Digest::MD5.hexdigest self.class.name
```
* Reformat exclude matrix to be easier to read
* Simplify jruby-travis config per rails/rails
* Organize .travis.yml per rails/rails
* Allow JRuby failure on Rails 5+; try rails-5 db adapter branch
https://github.com/jruby/activerecord-jdbc-adapter/issues/708
```
uninitialized constant ActiveRecord::ConnectionAdapters::Column::Format
```
see https://travis-ci.org/rails-api/active_model_serializers/jobs/277112008
If the `id` attribute for a class isn't taken directly from the object when
serializing it, it may be desirible for other classes that serialize a
relationship with that class to overwrite the relationship IDs they serialize.
For example, suppose we have:
```(ruby)
class Repo < Model
attributes :id, :github_id, :name
associations :configs
end
class Config < Model
attributes :id
belongs_to :repo
end
class RepoSerializer < ActiveModel::Serializer
attributes :id, :name
has_many :update_configs
def id
object.github_id
end
end
class ConfigSerializer < ActiveModel::Serializer
attributes :id
belongs_to :repo
end
```
In the above example, serializing a list of `Repo`s will give the `github_id`
for each one, but serializing a `Config` will give the `id` for its parent repo.
Ideally AMS would inspect the `RepoSerializer` when serializing the `Config`,
and realise it can't just output the foreign key. Unfortunately, getting the
serialization class for the child repo currently requires loading the record
(via evaluating `lazy_assocation`), and loses the performance benefit of the
existing `belongs_to?` path. Instead, I've opted to use
`read_attribute_for_serialization` instead of `object.send` to fetch the
serialized foreign key. This allows the serialized relationship ID to be
overwritten using
```(ruby)
class ConfigSerializer < ActiveModel::Serializer
...
def repo_id
object.repo.github_id
end
end
```
Also, fix test where attributes were included when id was ""
```
1) Failure:
ActionController::Serialization::AdapterSelectorTest#test_render_using_adapter_override
[test/action_c$ntroller/adapter_selector_test.rb:53]:
--- expected
+++ actual
@@ -1 +1 @@
-"{\"data\":{\"id\":\"\",\"type\":\"profiles\",\"attributes\":{\"name\":\"Name 1\",\"description\":\"Description 1\"}}}"
+"{\"data\":null}"
```