I recently started learning ruby on rails and I have been working on a public transport rating app API. Rails 6.0.3.2 I can't seem to shake off this error, I checked other questions but nothing is working for me kindly help me out.
Here is the controller (matatu_controller.rb)
module Api
module V1
class MatatusController < ApplicationController
# GET /api/v1/matatus
def index
matatus=Matatu.all
render json: MatatuSerializer.new(matatus).serialized_json
end
# POST /api/v1/matatus
def create
matatu=Matatu.new(matatu_params)
if matatu.save
render json: MatatuSerializer.new(matatu).serialized_json
else
render json: {error: matatu.errors.messages},status:422
end
end
private
def matatu_params
params.require(:matatu).permit(:name,:image_url)
end
end
end
end
The error
ActionController::ParameterMissing (param is missing or the value is empty: matatu)
it occurs when I try to a test if the API endpoints are working using postman
http://localhost:3000/api/v1/matatus
POST
here is JSON that should be added when I hit send
{"name":"crystal-bus"}