mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Merge remote-tracking branch 'upstream/master' into feature/adapter
This commit is contained in:
commit
b4a313e6d8
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,3 +16,4 @@ test/tmp
|
||||
test/version_tmp
|
||||
tmp
|
||||
*.swp
|
||||
.ruby-version
|
||||
@ -14,6 +14,4 @@ matrix:
|
||||
allow_failures:
|
||||
- rvm: ruby-head
|
||||
- env: "RAILS_VERSION=master"
|
||||
- env: "RAILS_VERSION=4.0"
|
||||
- env: "RAILS_VERSION=3.2"
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -121,7 +121,7 @@ The generated seralizer will contain basic `attributes` and
|
||||
|
||||
```ruby
|
||||
class PostSerializer < ActiveModel::Serializer
|
||||
attribute :title, :body
|
||||
attributes :title, :body
|
||||
|
||||
has_many :comments
|
||||
|
||||
@ -133,7 +133,7 @@ and
|
||||
|
||||
```ruby
|
||||
class CommentSerializer < ActiveModel::Serializer
|
||||
attribute :name, :body
|
||||
attributes :name, :body
|
||||
|
||||
belongs_to :post_id
|
||||
|
||||
|
||||
@ -68,8 +68,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
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user