[RUBY] [Rails] Let's create a super simple Rails API

Introduction

I made a rails API, so I will leave it as a memorandum. Next time I will try to introduce API documents such as swagger

How to make Rials API

Add --api to rails new

rails new rails-test-api --api

Easy to use

Generate CRUD This time I created a bulletin board CRUD

rails generate scaffold Board title:string text:string
rails db:create
rails db:migrate

Launch application

rails s

Connect to http: // localhost: 3000/boards

Hit POST with Curl where [] is displayed

curl -X POST -H "Content-Type: application/json" -d '{"title": "test", "text": "It's a test"}' http://localhost:3000/boards

Data is created when you connect to http: // localhost: 3000/boards again

[{"id":1,"title":"test","text":"It's a test","created_at":"2020-12-24T17:27:15.312Z","updated_at":"2020-12-24T17:27:15.312Z"}]

This completes

reference

https://railsguides.jp/api_app.html https://qiita.com/hanata-el/items/d96d84d1889b495aca00

Recommended Posts

[Rails] Let's create a super simple Rails API
[Rails withdrawal] Create a simple withdrawal function with rails
Let's create a REST API using WildFly Swarm.
[Rails DM] Let's create a notification function when DM is sent!
What beginners can learn by creating a simple Rails API
Preparing to create a Rails application
[Rails Tutorial Chapter 5] Create a layout
Rails API
[Rails6] Create a new app with Rails [Beginner]
Create a simple on-demand batch with Spring Batch
Let's create a Java development environment (updating)
Create a simple bar chart with MPAndroidChart
Create a RESTful API service using Grape
[rails] How to create a partial template
[Rails 5] Create a new app with Rails [Beginner]
Create a SPA with authentication function with Rails API mode + devise_token_auth + Vue.js 3 (Rails edition)
Nuxt.js × Create an application in Rails API mode
Let's create JUnit.
Create a simple search app with Spring Boot
[Rails] rails new to create a database with PostgreSQL
Let's create a timed process with Java Timer! !!
[Rails] How to create a graph using lazy_high_charts
Create a simple batch processing framework in Eclipse.
[Java] Create something like a product search API
Let's create a RESTful email sending service + client
Let's create a custom tab view in SwiftUI 2.0
Let's create a super-simple web framework in Java
Create a team chat with Rails Action Cable
[Java] Let's create a mod for Minecraft 1.16.1 [Introduction]
Let's make a search function with Rails (ransack)
How to easily create a pull-down in Rails
[Rails] How to create a Twitter share button
[Java] Let's create a mod for Minecraft 1.14.4 [99. Mod output]
Create a web api server with spring boot
Implement a reservation system using Rails and simple calendar! Let's add validation to datetime!
Place "Create a to-do list using Rails API mode and React Hooks" on docker
[Java] Let's create a mod for Minecraft 1.14.4 [0. Basic file]
[Java] Let's create a mod for Minecraft 1.14.4 [4. Add tools]
Create a docker image that runs a simple Java app
[Introduction] Try to create a Ruby on Rails application
Rails uninitialized constant A simple checklist for error resolution
[Java] Let's create a mod for Minecraft 1.14.4 [5. Add armor]
Create an EC site with Rails 5 ⑨ ~ Create a cart function ~
[Java] Let's create a mod for Minecraft 1.14.4 [Extra edition]
[Java] Let's create a mod for Minecraft 1.14.4 [7. Add progress]
[Java] Let's create a mod for Minecraft 1.14.4 [6. Add recipe]
Rails (API mode) x React x TypeScript simple Todo app
[Java] Let's create a mod for Minecraft 1.16.1 [Basic file]
If there is a state transition, let's create a State class
Let's create a gcloud development environment on a centos8 container
Implement a simple Rest API with Spring Security with Spring Boot 2.0
[Java] Let's create a mod for Minecraft 1.14.4 [1. Add items]
Let's make a robot! "A simple demo of Java AWT Robot"
Create a simple demo site with Spring Security with Spring Boot 2.1
[Java] Let's create a mod for Minecraft 1.14.4 [2. Add block]
[Java] Let's create a mod for Minecraft 1.16.1 [Add block]
<For super beginners> Why don't you make a chatbot using "Talk API"? ?? [Ruby on Rails]
[Java] Create a filter
Let's create a file upload system using Azure Computer Vision API and Azure Storage Java SDK
[Rails] Create an application
Tutorial to create a blog with Rails for beginners Part 1