Search code examples
ruby-on-railscancan

Cancan on a no model controller


I have a page with a configuration part where some users can edit element and variable of the site. I want to cancan controle the access to the page but as it's not a model, and I'm not sure how to do.

My controller

class ConfigurationController < ApplicationController
  def index
  end
end

My menu

<% if can?(:read, Configuration) # not sure of that  %> 
    <li><%= link_to t('texts.configuration.title'), configuration_index_path %></li>
<% end %>

I have a error with this code :

uninitialized constant ActionView::CompiledTemplates::Configuration

I'm actualy not sure of what mean this error. What will be the correct way to do that?

Thanks.


Solution

  • This is possible follow this post on Github it describe your problem and how to solve it:

    https://github.com/ryanb/cancan/issues/22

    and also this:

    CanCan and controllers without models