I want to send a response jsoncontaining a collection of my resource bookmarks. For some reason, the active model serializer just doesn't manipulate my json as expected. This gives only the default answer.
Here is my serializer BookmarksSerializerinapp/serializers/bookmarks_serializer.rb
class BookmarksSerializer < ActiveModel::Serializer
attributes :id, :url, :title
end
and my controller method is inside mine Api::UsersController, which has a filter respond_to :jsonon top
def index
user = User.find_by(username: params[:username])
@bookmarks = user.bookmarks
render json: @bookmarks.to_json
end
Instead of getting only: id,: title and: url, I get the full hash by default
What am I doing wrong? I use the rails 4.1.5github version of the active_model_serializers
gem.
gem 'active_model_serializers', github: 'rails-api/active_model_serializers'
FYI: show , . , . ,