Sha256: 5e1c5f33bac365336e8cb28c291176578db6b8b6cdb9e69651478c2cd237a0fd
Contents?: true
Size: 658 Bytes
Versions: 9
Compression:
Stored size: 658 Bytes
Contents
module Octodmin::Controllers::Posts class Update include Octodmin::Action expose :post params do param :layout, presence: true param :title, presence: true param :slug, presence: true param :date, presence: true param :content, presence: true end def call(params) self.format = :json @post = Octodmin::Post.find(params.env["router.params"][:id]) halt 400, JSON.dump(errors: ["Could not find post"]) unless @post halt 400, JSON.dump(errors: ["Required params are not specified"]) unless params.valid? @post.update(params.env["rack.request.form_hash"].dup) end end end
Version data entries
9 entries across 9 versions & 1 rubygems