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
等。如何在Rails中縮短控制器操作
我想索引/顯示/新只爲current_user。這是可行的,但我必須手動更改所有控制器操作。 而且我所有的自動化規格文件都只是測試@customer = customers
。
這似乎不是手動更換所有這些的方法。
有沒有更好的解決方案呢?
在此先感謝 最誠摯的問候 denym
你能澄清你到底在問什麼嗎? – drhenner