Skip to content
Kris Leech edited this page Jun 26, 2014 · 3 revisions

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

post do
  rate_topic = RateTopic.new

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

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

  rate_topic.execute(rating)
end