Rails 3.2
这是我的controllers / lead_billing / lead_billings_controller.rb:
在controllers / admin / lead_billings_controller.rb中,我有:
def create
@lead_billing = LeadBilling.new(params[:lead_billing])
@lead_billing.generate_model_id
@lead_billing.add_ticket_id_to_model(ticket_id)
@ticket = Ticket.find(params[:ticket_id])
respond_to do |format|
if @lead_billing.save
format.html { redirect_to @ticket, notice: 'Lead billing was successfully created.' }
format.json { render json: @lead_billing, status: :created, location: @lead_billing }
else
format.html { render action: "new" }
format.json { render json: @lead_billing.errors, status: :unprocessable_entity }
end
end
end
我想要做的是保存lead_billing,重新定向到门票控制器的show方法。
当我运行它时,我收到以下错误消息:
undefined method `ticket_url' for #<Admin::LeadBillingsController:0x0000000898c990>
与门票相关的路线:
tickets GET /tickets/:id(.:format) statics#tickets
update_state_admin_ticket PUT /admin/tickets/:id/update_state(.:format) admin/tickets#update_state
toggle_flag_admin_ticket PUT /admin/tickets/:id/toggle_flag(.:format) admin/tickets#toggle_flag
edit_notes_admin_ticket GET /admin/tickets/:id/edit_notes(.:format) admin/tickets#edit_notes
download_work_order_admin_ticket GET /admin/tickets/:id/download_work_order(.:format) admin/tickets#download_work_order
fancybox_show_admin_ticket GET /admin/tickets/:id/fancybox_show(.:format) admin/tickets#fancybox_show
to_step_admin_tickets GET /admin/tickets/to_step(.:format) admin/tickets#to_step
creator_admin_tickets GET /admin/tickets/creator(.:format) admin/tickets#creator
admin_tickets GET /admin/tickets(.:format) admin/tickets#index
POST /admin/tickets(.:format) admin/tickets#create
new_admin_ticket GET /admin/tickets/new(.:format) admin/tickets#new
admin_ticket GET /admin/tickets/:id(.:format) admin/tickets#show
PUT /admin/tickets/:id(.:format) admin/tickets#update
DELETE /admin/tickets/:id(.:format) admin/tickets#destroy
而不是给我看票。有什么想法吗?
答案 0 :(得分:1)
您的路线有admin_ticket
。试试redirect_to admin_ticket_path(@ticket)
。
答案 1 :(得分:0)
没有这样做,为什么不这样宣布呢?
redirect_to ticket_path(@ticket)