We are a software consultancy based in Berlin, Germany. We deliver
high quality web apps in short timespans.

Upstream Agile GmbH Logo

How to get resource route methodes for custom templates in rails

October 08, 2008 by alex

If you write a custom template handler, e.g. for pdf templates you might want to use the rails resource route methods e.g. new_users_path. Here is the way how to get this working for a imaginary PDF template handler.

class PdfRender

    attr_reader :controller
    #delegate the url_for call to the controller

    delegate :url_for, :to => :controller

    def initialize(action_view)
      @action_view = action_view
      @controller = action_view.controller
    ... # more handler code

#install routes for the handler

ActionController::Routing::Routes.named_routes.install PdfRenderer

Hello Explorer!

You’ve found our very old Website Archive (2007-2012). It’s a bit out of date, but we love looking back at how it all started - and how far we’ve come since then! We’re now fully focused on building our coworking management product, Cobot.

Take a look →