-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
No serializer found for resource #1250
Comments
can you post the model and serializer you expect it to use, and the controller action which tries to render with the serializer? |
also, the full backtrace, ruby version, rand rails version (this should really all be in CONTRIBUTING.md but appears to be missing) |
This is an expected situation for primitive associations, so we'll need more info to see why you're getting it. (It's handled later) |
model class Picture < ActiveRecord::Base
validates :title, presence: true, length: {minimum: 5 , maximum: 100 }
validates :url, presence: true
validates :user_id, presence: true
has_many :picture_comments
belongs_to :user
end Serializer class PicturesSerializer < ActiveModel::Serializer
attributes :id, :title, :url, :user_id, :rating, :created_at
has_one :user, serializer: SimpleUserSerializer
end SimpleUserSerializer class SimpleUserSerializer < ActiveModel::Serializer
attributes :id, :nick, :avatar
end grape controller module API
module V1
class Pictures < Grape::API
include API::V1::Defaults
format :json
formatter :json, Grape::Formatter::ActiveModelSerializers
resource :pictures do
desc "Return pictures paginate"
paginate per_page: 10, max_per_page: 200
params do
optional :top, type: Boolean
optional :from_date, type: Date
optional :to_date, type: Date
end
get "", root: :pictures, each_serializer: PicturesSerializer do
...
pictures = Picture.all.order(created_at: :desc)
paginate pictures
end
end
... |
still missing #1250 (comment)
the fact that you're using Grape and not Rails is incredibly important to share. The gem you're using is out of date https://github.com/jrhe/grape-active_model_serializers/blob/ca9c8faaa99727300ff21419aa20471ac27eed42/lib/grape-active_model_serializers/formatter.rb#L15-L25 |
I'm going to close this, since it's a grape gem issue. I'll help you with a PR there if you want, or even a monkey patch |
@rails-api/ams I'd be up for adding a grape integration to AMS. It would be easier for end-users to track changes, and shouldn't include much code or otherwise involve much |
is there any news? @marucjmar |
I am getting the same issue. Can anyone help me with this? |
@strivemag, @asampatoor Too old topic, I do not remember |
@strivemag, @asampatoor add this to your config.ru: require 'grape-active_model_serializers' |
@LeonidFilbert Thank you for the response. But that didn't fix the issue. |
AMS version -> 0.10.0.rc3
AMS version -> 0.9.3 All ok
The text was updated successfully, but these errors were encountered: