Finding controller relations in ActionController::Routing::R

Hi! my question is simple, the answer, i don’t know… Given this in
routes.rb:

ActionController::Routing::Routes.draw do |map|
map.resources :zones do |zone|
zone.resources :customers
end
end

If i’m “standing” on CustomersController, how can i inspect
ActionController::Routing::Routes to know that ZonesController is the
controller for my parent resource?

Thank you.

I have found a way to store resource information

$auto_rest_resources= []

class ActionController::Resources::Resource
alias_method :initialize_before_auto_rest, :initialize

def initialize *args
initialize_before_auto_rest(*args)
$auto_rest_resources << self
end
end

is there any better way to do this?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs