Forum: Ruby on Rails One of my routes is not working

Posted by mike (Guest)
on 2013-03-04 17:24
(Received via mailing list)
I have a User model which has_many :portfolios and each Portfolio 
has_many
:pictures. My routes look like this:

resources :users do
  resources :portfolios do
    resources :pictures
  endend

Then I try to create a new Portfolio like this:

<%= link_to "new portfolio...", new_user_portfolio_path(current_user) %>

With a form like this:

<%= form_for [current_user, @portfolio], html: { class: "form_settings" 
} do |f| %>...<% end %>

But when I click on "new portfolio..." my URL says 
/users/12/portfolios/new and I get this error:


No route matches {:action=>"show", :controller=>"portfolios", 
:user_id=><User id: 12, name: "michael", password_digest: 
"d787f56b080945c1ec0b3343cbf962ca427bb8ef", remember_token: 
"dL4nPlt0E5azUMemNIvkdg", admin: false, created_at: "2013-03-03 
01:18:19", updated_at: "2013-03-03 19:56:28">, :id=><Portfolio id: nil, 
user_id: 12, name: nil, created_at: nil, updated_at: nil>}
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.