Skip to content

Instantly share code, notes, and snippets.

@taketo1113
Last active December 21, 2018 08:46
Show Gist options
  • Select an option

  • Save taketo1113/2e1e43d191ae670e283921bb50340b78 to your computer and use it in GitHub Desktop.

Select an option

Save taketo1113/2e1e43d191ae670e283921bb50340b78 to your computer and use it in GitHub Desktop.

Revisions

  1. taketo1113 renamed this gist Dec 21, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. taketo1113 renamed this gist Dec 21, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. taketo1113 revised this gist Dec 21, 2018. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions readme
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,18 @@
    # Pundit Nested Headless policies

    ```
    ```ruby
    # app/policies/hoge/dashboard_policy.rb
    class Hoge::DashboardPolicy < Struct.new(:user, :dashboard)
    # ...
    end
    ```

    ```
    ```ruby
    # In controllers
    authorize [:hoge, :dashboard], :show?
    ```

    ```
    ```erb
    # In views
    <% if policy([:hoge, :dashboard]).show? %>
    <%= link_to 'Dashboard', dashboard_path %>
  4. taketo1113 created this gist Dec 21, 2018.
    24 changes: 24 additions & 0 deletions readme
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # Pundit Nested Headless policies

    ```
    # app/policies/hoge/dashboard_policy.rb
    class Hoge::DashboardPolicy < Struct.new(:user, :dashboard)
    # ...
    end
    ```

    ```
    # In controllers
    authorize [:hoge, :dashboard], :show?
    ```

    ```
    # In views
    <% if policy([:hoge, :dashboard]).show? %>
    <%= link_to 'Dashboard', dashboard_path %>
    <% end %>
    ```

    ## ref
    - pundit gem
    - https://github.com/varvet/pundit