首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >管理系统rails

管理系统rails
EN

Stack Overflow用户
提问于 2012-08-14 00:35:22
回答 1查看 56关注 0票数 0

我没有使用插件,而是使用教程http://ruby.railstutorial.org/chapters进行管理。然而,我遇到的问题如下

代码语言:javascript
复制
class UsersController < ApplicationController
  before_filter :signed_in_user, only: [:index, :edit, :update, :destroy]
  before_filter :correct_user,   only: [:edit, :update]
  before_filter :admin_user,     only: :destroy

我也想是如果你是admin_user然后能够编辑,并更新客户。但由于correct_user已被使用,它不能工作

我尝试过以下几种方法

代码语言:javascript
复制
def correct_customer
    @customer = Customer.find(params[:id])
    redirect_to(root_path) unless current_customer?(@customer) || customer.admin?
end

但是我有一个不确定的客户。什么是我最好的方法,让用户,如果管理员修改一个选定的客户。

如果我单击a customer#edit (而不是我),则会出现错误

代码语言:javascript
复制
NameError in CustomersController#edit

undefined local variable or method `customer' for #<CustomersController:0xa51fd60>
Rails.root: /home/jean/rail/map
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-14 01:08:29

我想你的意思是

代码语言:javascript
复制
redirect_to(root_path) unless current_customer?(@customer) || @customer.admin?
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11938501

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档