开发者

Yet another routing error in Rails3.1 when I tried to nest the resource

开发者 https://www.devze.com 2023-04-08 13:49 出处:网络
This is my error: No route matches {:controller=>\"accounts\", :format=>nil} and this is the url:

This is my error:

No route matches {:controller=>"accounts", :format=>nil}

and this is the url:

users/1/accounts/new

this is code in the routes.rb file:

resources :users do
  resources :accounts
end

OK, now I'm still confused about associations in Rails. The code above always uses the pluralized model name, like :users, :accounts.

Now, what if the relationship between user and account is one-to-one? Should开发者_JAVA技巧n't the code change to something like this?

resources :users do
  resources :account
end
0

精彩评论

暂无评论...
验证码 换一张
取 消