Access name_prefix from ApplicationController?

Hi all,

Long time lurker, first time poster.

I'm trying to use REST::RestController for my CRUD operations in an app, which works great unless I'm using a name_prefix in routes.db. In this case, it tries to send me to users_path instead of admin_users_path, which throws an exception.

Is there a way I can access the name_prefix from within REST::RestController, so I can modify the resource_path and resources_path methods to use the name_prefix if it's set?

Thanks

Hi all,

Long time lurker, first time poster.

I'm trying to use REST::RestController for my CRUD operations in an app, which works great unless I'm using a name_prefix in routes.db. In this case, it tries to send me to users_path instead of admin_users_path, which throws an exception.

Is there a way I can access the name_prefix from within REST::RestController, so I can modify the resource_path and resources_path methods to use the name_prefix if it's set?

As I can't figure out how to access the name_prefix, the other way that seems possible is to create an Admin::REST::RestController < REST::RestController, which overloads the resource_path and resources_path methods and hardcodes the '_admin' string.

So for the admin controllers I would use Admin::REST::RestController, and for the others I would use REST::RestController. This would still be DRY in my thinking because the only mmethods in the Admin version would be the two that return the path.

I don't like the hardcoded '_admin', but I can't see another way to do it.

Thanks, Wyatt