I’m writing a Rails plugin, and need to be able to dynamically determine which model a controller is associated with. For example, if I have a PeopleController, I need a clean way to determine that the controller handles Person models.
I’ve had a look through the API and haven’t found a method for it.
Is the only way to do this as a regexp combined with some ActiveSupport inflection trickery like singularize?
If so, are there any pitfalls with this approach? What are the edge cases?
It’s only a convention that a controller and model are related, so there is really no way to do it.
What are you trying to do?