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 6613715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:15:06+00:00 2026-05-25T20:15:06+00:00

I have a scoped resource in my routes file: scope :module => physical do

  • 0

I have a scoped resource in my routes file:

scope :module => "physical" do
    resources :mymodels
end

Using ‘> rake routes’ I get the standard routes, including:

mymodel GET    /mymodels/:id(.:format)    {:action=>"show", :controller=>"physical/mymodels"}

However when I use the console (and this is what’s failing in my tests) to get the url for instances of Mymodel I get errors:

> m = Physical::Mymodel.new
> => {...model_attributes...}
> m.save
> => true
> app.url_for(m)
> NoMethodError: undefined method `physical_mymodel_url' for #<ActionDispatch::Integration::Session:0x00000105b15228>
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/testing/assertions/routing.rb:175:in `method_missing'
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/routing/polymorphic_routes.rb:114:in `polymorphic_url'
from /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.7/lib/action_dispatch/routing/url_for.rb:133:in `url_for'
from (irb):13
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

This might be a gotcha, but Mymodel is also a subclass using the standard Rails single table inheritance.

Any thoughts? Why is it looking for physical_mymodel_url instead of mymodel_url? Any ideas for workarounds so that I can still use the unprefixed routes?

  • 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-25T20:15:06+00:00Added an answer on May 25, 2026 at 8:15 pm

    You’re only using the scope to tell it the module where the controller can be found in. If you want to use the physical prefix on your routes then you could do this:

    scope :module => "physical", :as => "physical" do
      resources :mymodel
    end
    

    Alternatively, you could just use the namespace method which will do the same thing:

    namespace :physical do
      resources :mymodel
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code in my routes.db file: resources :users do member do get
I'm using the friendly_id gem. I also have my routes nested: # config/routes.rb map.resources
I have this in my routes.rb scope '/admin' do root :to => 'home#index' resources
In my buy subdomain, I have the following routes: constraints Subdomain::Buy do scope module:
I'm using Rails 3 with Devise and have setup my routes.rb file like so:
I have such lines in routes.rb: scope /:subdomain/ do resource :order, :only => [:new,
I have the following routes defined: resources :patients do collection do get 'import' =>
I have following routes defined: CyberTrackRails3::Application.routes.draw do scope (:locale), :locale => /en|de|nl/ do resources
Is it possible to have scoped macros using custom defined macros through boost wave?
Imagine you have two defined routes: map.resources articles map.resources categories, :has_many => :articles both

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.