Skip to content
Dmitry Babenko edited this page Jun 14, 2016 · 3 revisions

When using Grape you need to explicitly use body within on blocks.

post do
  rate_topic = RateTopic.new

  rate_topic.on(:success) do |rating|
    status(200)
    body { message: "Woo hoo!" }
  end

  rate_topic.on(:failure) do |errors|
   render_api_error!(errors, 400)
  end

  rate_topic.execute(rating)
end