Home How to setup form_for with nested routes
 We have a namespaced model used in a namespaced controller, and an admin namespace inside that. Routes namespace: foos do namespace: admin do resources :bar end resources: bar, only: [:index, :show] end  Model module Foo class Bar < ActiveRecord::Base end end  Partial form_for @bar do end  This form will not render the correct path; which makes sense. That emits foos_bars_path, not a thing The route is actually foos_admin_bars_path But if we do form_for [:admin, @bar] it emits admin_foos_bars_path How can we get the path as we have it currently in routes? We are resorting to a url: some_helper_method_to_check_new_record but would prefer a cleaner way. Thanks. This is for Rails 4.2