I am trying to figure out various ways to create a create action in the Rails API. Here is what I have for my index action (which works) and my current implementation of my create action.
routes.rb file:
Rails.application.routes.draw do namespace :api do namespace :v1 do resources :vendors end end end
controller:
class Api::V1::SuyasController < ApplicationController def index render json: Suya.all end def create render json: Suya.create(suyas_params) end private def suyas_params require(:suya).permit(:meat, :spicy) end end
Do I need to use response_with / reply_to? This is abstracted by .gem respondents. If I do not want to use the stone of respondents, is this the best way to create api?
source share