레일즈로 생성 한 '트랜잭션'모델, 컨트롤러 및 뷰가 있습니다. 이제 컨트롤러 휘발성 명령으로 처리 할 응용 프로그램에/transactions/history의 단일 사용자 정의 경로를 추가해야합니다. ... end 및 render history.html.erb
내 routes.rb에 다음 행이 추가되었습니다. 레일에 단일 맞춤 경로를 추가하는 방법은 무엇입니까?
get '/transactions/history', to: 'transactions#history', as: 'transactions_history'
그리고 내 transactions_controller.rb이 : 레이크 경로를 호출 할 때 나는 또한이 줄을 참조
def history
@transactions = Transaction.all
end
및 transactions-에서 history.htmk.erb을 작성> 뷰
:
transactions_history GET /transactions/history(.:format) transactions#history
하지만 localhost를 요청할 때 : 브라우저에서 3000/거래/역사, 그것은 나에게 다음과 같은 오류 제공 :
Couldn't find Transaction with 'id'=history
을
before_action :set_transaction, only: [:show, :edit, :update, :destroy])
(나는 내 컨트롤러에서이 라인을 가지고 있기 때문에)
나는 또한 로그에이 줄을 참조하십시오
Request info
Request parameters
{"controller"=>"transactions", "action"=>"show", "id"=>"history"}
을 0
내 전체 경로 : routes.rb 내 전체 오류 : error logs 내 트랜잭션 컨트롤러의 '쇼'조치를 호출 이유는 무엇입니까?
전체 routes.rb 파일을 게시 할 수 있습니까? 그리고 당신이 루트를 긁어 모으는 것을 볼 수있는 내용의 전체 사본? – moveson