简体   繁体   English

没有模型控制器的Cancan

[英]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. 谢谢。

This is possible follow this post on Github it describe your problem and how to solve it: 可以在Github上关注此帖子,它描述了您的问题以及如何解决它:

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

and also this: 还有这个:

CanCan and controllers without models CanCan和没有模型的控制器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM