Comments (5)
Interesting - I'll take a look into how they handle the detection now and see how hard it would be to integrate into RP
from rocket_pants.
For people on rails 4.2 looking for easy workaround while issue not fixed:
I added this to initializers folder:
# Extracted from old active_model_serializers 0.8
# This patch fixes rocket_pants 1.11.0 compatibility with active_model_serializers 0.9
module ActiveModel::SerializerSupport
extend ActiveSupport::Concern
module ClassMethods #:nodoc:
if "".respond_to?(:safe_constantize)
def active_model_serializer
"#{self.name}Serializer".safe_constantize
end
else
def active_model_serializer
begin
"#{self.name}Serializer".constantize
rescue NameError => e
raise unless e.message =~ /uninitialized constant/
end
end
end
end
# Returns a model serializer for this object considering its namespace.
def active_model_serializer
self.class.active_model_serializer
end
alias :read_attribute_for_serialization :send
end
module ActiveModel::ArraySerializerSupport
def active_model_serializer
ActiveModel::ArraySerializer
end
end
Array.send(:include, ActiveModel::ArraySerializerSupport)
Set.send(:include, ActiveModel::ArraySerializerSupport)
{
:active_record => 'ActiveRecord::Relation',
:mongoid => 'Mongoid::Criteria'
}.each do |orm, rel_class|
ActiveSupport.on_load(orm) do
include ActiveModel::SerializerSupport
rel_class.constantize.send(:include, ActiveModel::ArraySerializerSupport)
end
end
Be sure to remove this code when issue will be fixed.
from rocket_pants.
There is a potential integration point for this in ActiveModel::Serializer.serializer_for
, but I want to test compatibility etc before implementing it first.
from rocket_pants.
For a start, given there is a work around for this - that is to say, you can manually set :serializer
or define your own active_model_serializer
method, I'm going to leave this out of 1.12 to avoid accidentally breaking stuff.
I'll retag this to 1.13, and take a look for that in the near future.
Again - patches / specs welcome :)
from rocket_pants.
Just a note, but I'm experimenting with bringing RP up to spec with AMS 0.10.x which has even further interface changes above and beyond 0.9.x
I'll let you know how I get on.
from rocket_pants.
Related Issues (20)
- :each_serializer doesn't seem to work HOT 3
- RSpec 3 uninitialized constant RSpec::Expectations::Differ HOT 12
- Automatically handled errors always return status code "200"? HOT 3
- Serializing an array of object should use the object serializer for individual objects HOT 2
- Deprecation warning `symbolized_path_parameters` when using Rails 4.2 HOT 4
- Misspell on "ArgumentError: please provide atleast one version" HOT 1
- Rails4 - How to inherit from RocketPants::Base correctly? HOT 2
- :response key breaks JSON API spec compatibility HOT 6
- ActionController::HideActions does not exist in Rails 5 HOT 2
- Is there a way to expose scoped associations in json? HOT 1
- Integration with Devise
- possible to do github-style api?
- Unable to pass options to serializer when using ActiveModelSerializers HOT 3
- Include full_messages in ActiveRecord validation response
- Can I use RokectPants with rails-api gem? HOT 2
- Is RocketPants still alive? HOT 2
- RocketPants + Rollbar HOT 1
- Kaminari 1.0 support HOT 1
- rails 5 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rocket_pants.