Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this a drop in replacement for active_model_serializers? #115

Closed
kapso opened this issue Mar 12, 2018 · 8 comments
Closed

Is this a drop in replacement for active_model_serializers? #115

kapso opened this issue Mar 12, 2018 · 8 comments
Labels
question Further information is requested

Comments

@kapso
Copy link

kapso commented Mar 12, 2018

Coz the serializer (see below) is not working and I get this error - NoMethodError (undefined method order_date' for #Order:0x00007fb6b78c4748)`

active_model_serializers does allow you to attach attributes to local methods, looks like this gem does not allow this?

class OrderSerializer
  include FastJsonapi::ObjectSerializer

  attributes :id, :total_price_cents, :order_date
  
  # order_date is not a method/attribute on Order model
  def order_date
    Time.current.to_s
  end
end
@citizen428
Copy link

#54 Adds a way to define custom attributes via a block, but there's been no gem release since this PR got merged.

@shishirmk
Copy link
Collaborator

It is not a drop in replacement for AMS. However it is very similar to AMS so it should be easy to migrate. However note that fast_jsonapi only serializes to json:api spec

@shishirmk shishirmk added the question Further information is requested label Mar 13, 2018
@kapso
Copy link
Author

kapso commented Mar 13, 2018

@citizen428 any plans of doing it via a method. Block is nice, but a method has its advantages - mixins, inheritance to extend behavior.

@citizen428
Copy link

@kapso I don't know, I'm not a developer on this project, I just recently had the same question. There were alternative PRs but to the best of my knowledge none of them got merged yet.

@kapso
Copy link
Author

kapso commented Mar 13, 2018

@citizen428 thanks for the clarification.

@shishirmk any chances of merging changes that use a method instead of attribute block?

@guilleiguaran
Copy link
Contributor

@kapso we will resume the discussion about custom methods and what's the best for implementing it after of 1.1.0 release 😊

@kapso
Copy link
Author

kapso commented Mar 13, 2018

@guilleiguaran got it, thanks. Whats the timeline for 1.1.0 release?

@shishirmk
Copy link
Collaborator

@kapso 1.1.0 has been released. Closing this as the question is answered. There is a separate open issue and pull request for supporting custom attributes through methods instead of block so i am going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants