How to create a blog in Ruby on Rails API part 2 - creating, updating, and deleting

Now that you have a model and can display out the blog posts, we want to be able to create, update, and delete more posts. But what about making sure the post is only editable by the proper user? And what format do we want to send them to our frontends in via our API? In this episode, we'll create API endpoints for create, update, and delete, and then explore the Pundit Gem and the jsonapi-serializer Gem based on https://jsonapi.org/.
🤯 Support on Patreon
  • https://www.patreon.com/davidwparker

⏱️ Timestamps:
  • 00:00 - Introduction
  • 00:50 - Test coverage results
  • 01:20 - Gemfile
  • 02:05 - JSON API Serializer and jsonapi.org spec
  • 03:45 - Pundit Gem
  • 04:15 - posts controller and logic changes for create, update and delete
  • 10:45 - adding Pundit / how pundit works
  • 18:45 - adding specs to test access

💌 Newsletter:
  • https://www.programmingtil.com/

🪐Elsewhere:
  • Twitter: https://twitter.com/davidwparker
  • Twitter: https://twitter.com/programmingtil
  • GitHub: https://github.com/davidwparker

💭Concepts:
  • Create, update and delete API endpoints for our Blog Post model

📚Resources:
  • https://github.com/davidwparker/programmingtil-rails/tree/ep16
  • https://jsonapi.org/
  • https://github.com/jsonapi-serializer/jsonapi-serializer
  • https://github.com/varvet/pundit

🎬 Subscribe!
  • http://bit.ly/subdavidwparker

My name is David W Parker and I’m creating and publishing videos on ProgrammingTIL to help teach anyone and everyone who wants to code. I’m a huge fan of Ruby on Rails, Svelte, TailwindCSS, and WebGL. I’ve used React a lot in the past, as well as some Vue and AngularJS. I’ve done some professional Python and Django. I like to create real applications and my tutorials will walk you through how to build something real from beginning-to-end.

ruby #rails #rubyonrails

© programmingtil.com