Skip to content
Permalink
Browse files

Guides: expand Action Request & Response with #status

  • Loading branch information...
jodosha committed May 18, 2015
1 parent 6f8e487 commit bb5469f17db3e5439897df563977203190c7b3d3
Showing with 18 additions and 2 deletions.
  1. +18 −2 source/guides/actions/request-and-response.md
@@ -60,11 +60,27 @@ module Web::Controllers::Dashboard
def call(params)
self.status = 201
self.body = 'Hi!'
self.body = 'Your resource has been created'
self.headers.merge!({ 'X-Custom' => 'OK' })
end
end
end
# It will return [201, { "X-Custom" => "OK" }, ["Hi!"]]
# It will return [201, { "X-Custom" => "OK" }, ["Your resource has been created"]]
```

As shortcut we can use `#status`.

```ruby
# apps/web/controllers/dashboard/index.rb
module Web::Controllers::Dashboard
class Index
include Web::Action
def call(params)
status 201, "Your resource has been created"
end
end
end
# It will return [201, {}, ["Your resource has been created"]]

0 comments on commit bb5469f

Please sign in to comment.
You can’t perform that action at this time.