I’m working on a gem that will respond to certain paths, rendering its own content for them. For example:
/my_gem_path
would be recognized by the gem, and it would render its own view, so the application using the gem would not be involved (at least insofar as a controller or view).
The problem i’m having is that ‘/my_gem_path’ is not mapped as a route, because there is no controller that exists with that name, and there is no entry in routes for that path.
I’m wondering:
- If/how the gem can add its own route when it loads? Or does the application have to define a route?
- If the render occurs from the application_controller (say in a before_filter), what that route might look like?
- If i’m going about this all wrong?
Thanks for your time!
Instead of a gem, you want to be focusing on creating an “engine”. And engine can be mounted at /my_gem_path and take over from there
Ryan has great stuff on engines here: http://ryanbigg.com/guides/engines.html