5

I am using CanCan 2.0 gem for authorization and high_voltage gem for static pages.

In my routes.rb file I have:

match 'about' => 'high_voltage/pages#show', id: 'about'

And I want to make it public in my ability.rb file, but none of these two lines do that:

can :read, :pages
can :read, 'high_voltage/pages'

How do I fix this?

krn
  • 6,715
  • 14
  • 59
  • 82

2 Answers2

2

Isn't this problem related to the fact that there is no model 'Page'? There is cancan wiki, how to deal with this situation: it should work when you add

authorize_resource :class => false

to your controller.

santuxus
  • 3,662
  • 1
  • 29
  • 35
-2

If it's static pages in the traditional sense, then that won't work. Static pages completely bypass the Rails stack and are served directly from the file system. What I would recommend doing is still caching these as static pages, but having a controller that checks the permission and then serves the static page.

Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261