From f02f5b767a3c8ac213476ebbbaa3ff28d5566b22 Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Wed, 27 Aug 2014 11:48:14 +0200 Subject: [PATCH 1/5] README: typo fix on attributes --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 666d9a2f..441a5379 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ serializers: ```ruby class PostSerializer < ActiveModel::Serializer - attribute :title, :body + attributes :title, :body has_many :comments @@ -43,7 +43,7 @@ and ```ruby class CommentSerializer < ActiveModel::Serializer - attribute :name, :body + attributes :name, :body belongs_to :post @@ -115,7 +115,7 @@ The generated seralizer will contain basic `attributes` and ```ruby class PostSerializer < ActiveModel::Serializer - attribute :title, :body + attributes :title, :body has_many :comments @@ -127,7 +127,7 @@ and ```ruby class CommentSerializer < ActiveModel::Serializer - attribute :name, :body + attributes :name, :body belongs_to :post_id From c8d9ee4ae3b62ff9427ce9485a7447296e1ae7ef Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Wed, 27 Aug 2014 10:53:34 -0400 Subject: [PATCH 2/5] Fix rails 4.0.x build --- test/test_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 3fd3776c..b7875f75 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -5,6 +5,8 @@ require 'action_controller' require 'action_controller/test_case' require "active_support/json" require 'minitest/autorun' +# Ensure backward compatibility with Minitest 4 +Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) require "active_model_serializers" From fbf8633041cc10f2d5a27118a138802932e2a334 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Wed, 27 Aug 2014 10:54:14 -0400 Subject: [PATCH 3/5] Dont allow failures on 4.0.x --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 49262de1..d54edc2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,4 @@ matrix: allow_failures: - rvm: ruby-head - env: "RAILS_VERSION=master" - - env: "RAILS_VERSION=4.0" - env: "RAILS_VERSION=3.2" - From 373c35959a322eea13c7d8c19196ac2700dc20a0 Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Wed, 27 Aug 2014 10:54:38 -0400 Subject: [PATCH 4/5] Add .ruby-version to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f61f58b8..838a74e0 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ test/tmp test/version_tmp tmp *.swp +.ruby-version \ No newline at end of file From dee2f1969e2c8e73b1ef3b17302ef7c36c81088b Mon Sep 17 00:00:00 2001 From: Tony Pitale Date: Wed, 27 Aug 2014 14:42:41 -0400 Subject: [PATCH 5/5] Rails does not support const_defined? in development mode; Use const_get instead, and rescue NameError --- lib/active_model/serializer.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/active_model/serializer.rb b/lib/active_model/serializer.rb index c06c58a0..b94b8a46 100644 --- a/lib/active_model/serializer.rb +++ b/lib/active_model/serializer.rb @@ -67,8 +67,10 @@ module ActiveModel else serializer_name = "#{resource.class.name}Serializer" - if Object.const_defined?(serializer_name) + begin Object.const_get(serializer_name) + rescue NameError + nil end end end