Last active
December 21, 2018 08:46
-
-
Save taketo1113/2e1e43d191ae670e283921bb50340b78 to your computer and use it in GitHub Desktop.
Revisions
-
taketo1113 renamed this gist
Dec 21, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
taketo1113 renamed this gist
Dec 21, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
taketo1113 revised this gist
Dec 21, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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 %> -
taketo1113 created this gist
Dec 21, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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