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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:27:56+00:00 2026-05-18T08:27:56+00:00

In the rails 2 version of my app I have this resource defined map.resources

  • 0

In the rails 2 version of my app I have this resource defined

map.resources :albums, :as => 'music', :has_many => :reviews

This gave me some standard routes:

album GET    /music/:id(.:format) {:controller=>"albums", :action=>"show"}
new_album GET    /music/new(.:format) {:controller=>"albums", :action=>"new"}

I also have a polymorphic association set up as follows:

class Album < ActiveRecord::Base
  has_many :reviews, :as => :reviewable
end


class Review < ActiveRecord::Base
  belongs_to :reviewable, :polymorphic => true
end

This meant I could create a link to my album resource through my review by using a polymorphic path

<%= review.reviewable.title, polymorphic_path(review.reviewable) %>

However, since upgrading to rails 3 I’ve changed my routes file to in order to comply with the new router:

resources :music, :controller => 'albums' do
  resources :reviews
end

And although cleaner it breaks my polymorphic link, i.e.

<%= review.reviewable.title, polymorphic_path(review.reviewable) %>

I end up with the following error message

undefined method `album_path' 

If I look in my rails 3 generated routes with “rake routes” i see

music GET    /music/:id(.:format) {:action=>"show", :controller=>"albums"}

which is different to what was there before in the rails 2, i.e.

album GET    /music/:id(.:format) {:controller=>"albums", :action=>"show"}

So my guess is that this is what’s breaking things.

I’m a little unsure though as how to fix it without reverting back to the rails 2 routes which will be depreciated with rails 3.1. Any help would be appreciated. Thanks.

  • 1 1 Answer
  • 2 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-18T08:27:57+00:00Added an answer on May 18, 2026 at 8:27 am

    It turns out this was easy to fix. All I had to do was:

    resources :albums, :path => 'music' do
      resources :reviews
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app based on Rails 3 (version Rails 3.1.2 ) and ruby
I have added the Devise gem to the ruby on rails app version 1.8.7.
All this weekend I have been trying to setup a Rails 3.0.4 app in
I have a sqlite3 db in a rails app with the following schema ActiveRecord::Schema.define(:version
I have the following in my Rails 3 app photo view: <% for version
I have a rails app that uses PDFKit to render pdf versions of webpages.
I created sample rails app and deployed into heroku. Rails version is 3.1.3 Ruby
How does one approach building the mobile app version of one's Rails app, with
I had the gmaps4rails gem version 1.4.5 working nicely on my Rails 3.2.2 app.
This is basically a rails 3 version of this question . Short of parsing

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.