Open Mirv opened 6 years ago
Note: ... suggested an initializer for api
If we now request a single user it will also render all microposts, followers and followings (users that the user follows). Usually we don’t want that but instead we probably want AMS to render only the ids. In an initializer add:
ActiveModel::Serializer.setup do |config|
config.embed = :ids
end
Tip: Exceptions in Ruby are quite slow. A faster way is to request the user from the db using findby and render 404 if findby returned a nil.
inserted base serializer class from his github ... https://github.com/vasilakisfil/rails5_api_tutorial/blob/master/app/serializers/api/v1/base_serializer.rb
Need to work out different between gem 'active_model_serializers'
& getting it from github directly.
Index might have been working using the direct github DL ... then the bundle had issues installing - I think i got it working using gem install active_model_serializers
... later it's not recognizing the namespace.
gem install active_model_serializers # failed to fix
https://blog.kollegorna.se/build-an-api-in-your-rails-app-now-c29b99a55d7b
api controllers
[x] base
[x] dashes
[x] users
[x] players
[x] campaigns
[x] countries
router
[ ] base
[x] dashes
[x] users
[x] players
[x] campaigns
[x] countries
serializers
show
[ ] base
[ ] dashes
[x] users
[x] players
[ ] campaigns
[ ] countries
index
[ ] base
[ ] dashes
[x] users
[x] players
[ ] campaigns
[ ] countries
got all my controllers & routes set for new api on top of my normal basicB rails app in like 30 mins ... need to finish writing serializations for it though