Class: Octodmin::Controllers::Posts::Create
- Inherits:
-
Object
- Object
- Octodmin::Controllers::Posts::Create
- Includes:
- Action
- Defined in:
- app/controllers/posts/create.rb
Instance Method Summary collapse
Instance Method Details
#call(params) ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/controllers/posts/create.rb', line 10 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 |