Sha256: 6dcd1f101a5e3f7bd5e74b3ec076cbabe0646c866faf204838fd004c8280edf1
Contents?: true
Size: 476 Bytes
Versions: 9
Compression:
Stored size: 476 Bytes
Contents
module Octodmin::Controllers::Posts class Create include Octodmin::Action expose :post params do param :title, presence: true end def call(params) self.format = :json halt 400, JSON.dump(errors: ["Required param `title` is not specified"]) unless params.valid? @post = Octodmin::Post.create(title: params[:title]) halt 400, JSON.dump(errors: ["Post with specified `title` already exists"]) unless @post end end end
Version data entries
9 entries across 9 versions & 1 rubygems