Merb でネストされたリソースを破棄する方法を探しています。私の現在の方法はほぼ正しいようですが、ネストされたオブジェクトの破棄中にコントローラーがInternalServerErrorを発生させます。
ここにリクエストに関するすべての詳細が表示されます。詳細についてはお気軽にお問い合わせください :)
ありがとう、
アレックス
次のルートを使用して、ネストされたリソースを破棄しようとしています
router.resources :events, Orga::Events do |event|
event.resources :locations, Orga::Locations
end
jQueryリクエストで得られるもの(delete_メソッドは、「DELETE」を使用した$.ajaxの実装です):
$.delete_("/events/123/locations/456");
Locationコントローラー側では、次のものを持っています:
def delete(id)
@location = Location.get(id)
raise NotFound unless @location
if @location.destroy
redirect url(:orga_locations)
else
raise InternalServerError
end
end
そしてログ:
merb : worker (port 4000) ~ Routed to: {"format"=>nil, "event_id"=>"123", "action"=>"destroy", "id"=>"456", "controller"=>"letsmotiv/locations"}
merb : worker (port 4000) ~ Params: {"format"=>nil, "event_id"=>"123", "action"=>"destroy", "id"=>"456", "controller"=>"letsmotiv/locations"}
~ (0.000025) SELECT `id`, `class_type`, `name`, `prefix`, `type`, `capacity`, `handicap`, `export_name` FROM `entities` WHERE (`class_type` IN ('Location') AND `id` = 456) ORDER BY `id` LIMIT 1
~ (0.000014) SELECT `id`, `streetname`, `phone`, `lat`, `lng`, `country_region_city_id`, `location_id`, `organisation_id` FROM `country_region_city_addresses` WHERE `location_id` = 456 ORDER BY `id` LIMIT 1
merb : worker (port 4000) ~ Merb::ControllerExceptions::InternalServerError - (Merb::ControllerExceptions::InternalServerError)