Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gadikotamohan committed Jan 6, 2016
1 parent a50cc3c commit a585cf8
Showing 1 changed file with 57 additions and 2 deletions.
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ require "sprockets/railtie"
require "rails/test_unit/railtie"
```

In config/environments/development.rb, remove or comment out
## In config/environments/development.rb, remove or comment out

`config.active_record.migration_error = :page_load`


you have to remove active_record helpers from the spec_helper

In application.rb
## In application.rb

`config.app_middleware.delete "ActiveRecord::ConnectionAdapters::ConnectionManagement"`

Expand Down Expand Up @@ -55,4 +55,59 @@ test:
production:
<<: *default
```

## For authentication
Used [Devise](https://github.com/neo4jrb/devise-neo4j)

## For authorization
Used [Pundit](https://github.com/elabs/pundit)

## Problem with namespaces in Pundit
Issue [Namespace Issue](https://github.com/elabs/pundit/issues/12)

### My Solution

policy/dashboard/home_policy.rb

```
module Dashboard
class HomePolicy < DashboardPolicy
def initialize(user, record)
@user = user
@record = record
end
def show?
@user.present?
end
end
end
```

policy/home_policy.rb

```
class HomePolicy < ApplicationPolicy
def initialize(user, record)
@user = user
@record = record
end
def show?
true
end
end
```

dashboard/home_controller.rb
```
def show
# send name of controller, which is the policy's qualifying name.
# and that's it voila.
authorize :"#{params[:controller]}", :show?
end
```

0 comments on commit a585cf8

Please sign in to comment.