Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:48:43+00:00 2026-05-28T01:48:43+00:00

So here’s the routes in question: resources :subjects, path: ‘library’ do resources :modules, controller:

  • 0

So here’s the routes in question:

  resources :subjects, path: 'library' do
    resources :modules, controller: 'subject_modules'
  end

When I write form_for [@subject, @subject_module] (with those two set to what you’d expect), Rails tries to generate “subject_subject_module_path”.

When I remove the :path for the subjects resource, the generated helper remains the same (as expected).

What it should be is “subject_module_path”; I suspect the problem is that Rails looks at the controller for the modules resources and uses that instead of its actual path, i.e. it builds this helper:

subject_ + subject_module_ + path

From what I’ve gathered so far, it’s pointing towards the possibility of a bug, but is it possible it’s more something on my side or something intended by design?

For now, I suppose this is usable as a temporary fix:

form_for([@subject, @subject_module], url: subject_module_path(@subject, @subject_module))

I’m using Rails 3.1.3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:48:43+00:00Added an answer on May 28, 2026 at 1:48 am

    This is something that occurs due to the design of Rails.

    The following is what the Rails API docs say in relation to url_for:

    Relying on named routes

    Passing a record (like an Active Record or Active Resource) instead of
    a Hash as the options parameter will trigger the named route for that
    record. The lookup will happen on the name of the class. So passing a
    Workshop object will attempt to use the workshop_path route. If you
    have a nested route, such as admin_workshop_path you’ll have to call
    that explicitly (it’s impossible for url_for to guess that route).

    But saying explicitly declaring a helper is required when you have a “nested route” is in accurate. If the nesting occurs under a resource (without certain kinds of routing options, more on this later), Rails will be able to generate the path without any issues.

    form_for appears to at some point, like url_for, call polymorphic_url in order to generate the URL to target, which in turn calls build_named_route_call.

    You can see that build_named_route_call simply generates underscored_versions of the ModelNames passed in, and joins them together with underscores.

    Bringing that back to my routing:

      resources :subjects, path: 'library' do
        resources :modules, controller: 'subject_modules'
      end
    

    Since the subjects resource is under /library/ by setting :path, its helpers remain as subjects_*, and thus Rails has no problems generating a URL for it when passed a Subject. The subject_modules resource (named as such since Rails reserves the name Module for models) however, has had its named helpers changed from its model name through the setting of :controller.

    Mystery solved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my problem : I have a post controller with the action create.
Here a simple question : What do you think of code which use try
Here is my question. I am having this simple menu. <div id=menu> <ul> <li>
Here is an example: I write html code inside of textarea, then I swap
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is my code, which takes two version identifiers in the form 1, 5,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.