Skip to content

Commit

Permalink
Fix documentation for rails examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Jun 23, 2012
1 parent f00bdbc commit 2136002
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions README.md
Expand Up @@ -30,6 +30,8 @@ By default when the Rack application is loaded no cookies will be set(provided n
Rack::Policy::CookieLimiter consent_token: 'allow_me'
```

The very same `consent_token` is used to toggle the limiter behaviour.

## Examples

### Rails 3.x
Expand All @@ -47,18 +49,18 @@ And then in your custome controller create actions responsible for setting and u

```ruby
class CookiePolicyController < ApplicationController

def allow
cookies[:consent_token] = {
response.set_cookie 'rack.policy', {
value: 'true',
expires: 1.year.from_now.utc
}
render nothing: true
end

def deny
cookies[:consent_token] = {
value: '',
expires: Time.at(0)
}
response.delete_cookie 'rack.policy'
render nothing: true
end
end
```
Expand All @@ -77,6 +79,8 @@ Set and unset cookie consent in similar way to Rails 3.x example.

### Sinatra

For classic style sinatra application do

```ruby
require 'sinatra'
require 'rack/policy'
Expand All @@ -86,6 +90,8 @@ use Rack::Policy::CookieLimiter consent_token: 'rack.policy'
get('/hello') { "Hello world" }

get('/allow') { }

get('/deny') { }
```

### Rackup app
Expand Down

0 comments on commit 2136002

Please sign in to comment.