2

I have a typical artist has_many songs model and I'm trying to set up the nested resource in Rails.

My routes.rb looks like this:

map.resources :artists do |artist|
   map.resources :songs
end

This works fine for the artist paths, but when I want to link to the songs controller, like this:

<%= link_to artist.name, artist_songs_path(artist) %>

my links look like this:

/songs.<artist:0x22b77ec>

Where it should probably look like /artist/5/songs

I'm sure it's something stupid I've missed, but I don't see it. Ideas?

1
  • 2
    Doh! as soon as I posted this I saw my error. the nested route should be artist.resources :songs, not map.resources :songs. Should I leave the question here for others? Commented Jun 14, 2009 at 19:49

1 Answer 1

1

Ummm.... I think you should change map.resources :songs to artist.resources :songs...

Yes. leave the answer around. Maybe retag it with rails routes mistakes...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.