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方式。
有没有更好的解决方案?
在此先感谢 最好的问候否认