私のアプリケーションはチケットと call_logs を使用しています。チケットが多くの call_log を持つことができるように、これらを互いに入れ子にしています。[GET] "/call_logs" でエラーが発生しています。何が欠けているのかわかりません。
私は自分のルートをroutes.rbにネストしています
resources :tickets do
resources :call_logs
end
レーキ ルート:
ticket_call_logs GET /tickets/:ticket_id/call_logs(.:format) call_logs#index
POST /tickets/:ticket_id/call_logs(.:format) call_logs#create
new_ticket_call_log GET /tickets/:ticket_id/call_logs/new(.:format) call_logs#new
edit_ticket_call_log GET /tickets/:ticket_id/call_logs/:id/edit(.:format) call_logs#edit
ticket_call_log GET /tickets/:ticket_id/call_logs/:id(.:format) call_logs#show
PUT /tickets/:ticket_id/call_logs/:id(.:format) call_logs#update
DELETE /tickets/:ticket_id/call_logs/:id(.:format) call_logs#destroy
tickets GET /tickets(.:format) tickets#index
POST /tickets(.:format) tickets#create
new_ticket GET /tickets/new(.:format) tickets#new
edit_ticket GET /tickets/:id/edit(.:format) tickets#edit
ticket GET /tickets/:id(.:format) tickets#show
PUT /tickets/:id(.:format) tickets#update
DELETE /tickets/:id(.:format) tickets#destroy
call_logs コントローラー:
class CallLogsController < ApplicationController
before_filter :get_ticket
# GET /call_logs
# GET /call_logs.json
def index
@call_logs = @ticket.call_logs.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @call_logs }
end
# GET /call_logs/1
# GET /call_logs/1.json
def show
@call_log = @ticket.call_logs.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @call_log }
end
end
# GET /call_logs/new
# GET /call_logs/new.json
def new
@call_log = @ticket.call_logs.build
respond_to do |format|
format.html # new.html.erb
format.json { render json: @call_log }
end
end
# GET /call_logs/1/edit
def edit
@call_log = @ticket.call_logs.find(params[:id])
end
# POST /call_logs
# POST /call_logs.json
def create
@call_log = CallLog.new(params[:call_log])
respond_to do |format|
if @call_log.save
format.html { redirect_to ticket_call_logs_url(@ticket), notice: 'Call log was successfully created.' }
format.json { render json: @call_log, status: :created, location: @call_log }
else
format.html { render action: "new" }
format.json { render json: @call_log.errors, status: :unprocessable_entity }
end
end
end
# PUT /call_logs/1
# PUT /call_logs/1.json
def update
@call_log = @ticket.call_logs.find(params[:id])
respond_to do |format|
if @call_log.update_attributes(params[:call_log])
format.html { redirect_to ticket_call_logs_url(@ticket), notice: 'Call log was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @call_log.errors, status: :unprocessable_entity }
end
end
end
# DELETE /call_logs/1
# DELETE /call_logs/1.json
def destroy
@call_log = @ticket.call_log.find(params[:id])
@call_log.destroy
respond_to do |format|
format.html { redirect_to ticket_call_logs_path(@call_log)}
format.json { head :no_content }
end
end
end
end
private
def get_ticket
@ticket = Ticket.find(params[:ticket_id])
end
call_log ページに移動するときに URL パスにエラーがあると思いますが、それが見つからないようです。私は初心者なので、アドバイスやヒントをいただければ幸いです。ありがとうございました。