【发布时间】:2013-05-20 02:04:44
【问题描述】:
def index
@customers = current_user.customers
respond_to do |format|
format.html # index.html.erb
format.json { render json: @customers }
end
end
def show
@customer = current_user.customers.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @customer }
end
end
def new
@customer = current_user.customers.new
end
这是我的 CustomerController 的一小部分。来源@customers 是@customers = customers 等等。
我只想为 current_user 索引/显示/新建。这是有效的,但我必须手动更改所有控制器操作。
而且我所有的自动化规范文件都只是测试@customer = customers。
这似乎不是手动更改所有这些的 Rails 方式。
有没有更好的解决方案?
提前致谢 最好的祝福 否认
【问题讨论】:
-
你能澄清你到底在问什么吗?
标签: ruby-on-rails-3 controller ruby-on-rails-3.2