-1
嗨,我有一个函数来检查,如果电流控制器+操作包括在数组列表,但它不是在这里工作是我的代码Rails 4 array.include?问题
功能
def verify
cur_path = params[:controller] +'/'+ params[:action]
confirm_access(cur_path)
end
def confirm_access(section)
user_group = UserGroup.find(1)
allowed_acl = Array.new
user_group.access_sections.each do |d|
allowed_acl << d.section
end
if allowed_acl.include? section
return true
else
#false
end
end
但是当我通过confirm_access(“串” )静态字符串它正在工作,但不与cur_path变量。
'allowed_acl'从哪里来? –
有点偏离主题:你的'confirm_access'方法可能只包含'allowed_acl.include? section'。有没有必要把它包装在'if .. return ... else return ...' – GolfWolf
@mr rogers请现在检查我已经包括'allowed_acl'数组 –