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에 대해서만/show/new를 색인 싶었습니다. 이 작동하지만 모든 컨트롤러 작업을 수동으로 변경해야했습니다. 또한 모든 자동화 된 사양 파일은 @customer = customers
에 대한 테스트 중입니다.
이것은 수동으로 모든 것을 바꾸는 레일 방식이 아닙니다.
더 나은 솔루션이 있습니까? 사전에
감사 안부 denym
정확히 무엇을 묻고 있습니까? – drhenner