У меня проблема с вложенными ресурсами.
2 Модели
User => has_many :stuffs
Stuff => belongs_to :user
routes.rb
map.resources :stuffs
map.resources :users, :has_many => [:stuffs]
Когда я звоню / users / 1 / stuffs, он представляет мне материал для соответствующего пользователя. но я получил это также, когда я звоню / users / 2 / stuffs. Он должен возвращать 0 "Stuffs", но он не работает.
MySQL Query from Server
SELECT * FROM `stuffs`
Рейк-маршруты
stuffs GET /stuffs(.:format) {:action=>"index", :controller=>"stuffs"}
POST /stuffs(.:format) {:action=>"create", :controller=>"stuffs"}
new_stuff GET /stuffs/new(.:format) {:action=>"new", :controller=>"stuffs"}
edit_stuff GET /stuffs/:id/edit(.:format) {:action=>"edit", :controller=>"stuffs"}
stuff GET /stuffs/:id(.:format) {:action=>"show", :controller=>"stuffs"}
PUT /stuffs/:id(.:format) {:action=>"update", :controller=>"stuffs"}
DELETE /stuffs/:id(.:format) {:action=>"destroy", :controller=>"stuffs"}
user_stuffs GET /users/:user_id/stuffs(.:format) {:action=>"index", :controller=>"stuffs"}
POST /users/:user_id/stuffs(.:format) {:action=>"create", :controller=>"stuffs"}
new_user_stuff GET /users/:user_id/stuffs/new(.:format) {:action=>"new", :controller=>"stuffs"}
edit_user_stuff GET /users/:user_id/stuffs/:id/edit(.:format) {:action=>"edit", :controller=>"stuffs"}
user_stuff GET /users/:user_id/stuffs/:id(.:format) {:action=>"show", :controller=>"stuffs"}
PUT /users/:user_id/stuffs/:id(.:format) {:action=>"update", :controller=>"stuffs"}
DELETE /users/:user_id/stuffs/:id(.:format) {:action=>"destroy", :controller=>"stuffs"}
users GET /users(.:format) {:action=>"index", :controller=>"users"}
POST /users(.:format) {:action=>"create", :controller=>"users"}
new_user GET /users/new(.:format) {:action=>"new", :controller=>"users"}
edit_user GET /users/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
user GET /users/:id(.:format) {:action=>"show", :controller=>"users"}
PUT /users/:id(.:format) {:action=>"update", :controller=>"users"}
DELETE /users/:id(.:format) {:action=>"destroy", :controller=>"users"}
root / {:action=>"index", :controller=>"users"}
список драгоценных камней
actionmailer (2.3.8)
actionpack (2.3.8)
activerecord (2.3.8)
activeresource (2.3.8)
activesupport (2.3.8)
arel (2.0.6)
authlogic (2.1.6)
builder (2.1.2)
cgi_multipart_eof_fix (2.5.0)
gem_plugin (0.2.3)
i18n (0.5.0)
mongrel (1.1.5 x86-mingw32)
mysql (2.8.1 x86-mingw32)
paperclip (2.3.7)
rack (1.1.0)
rails (2.3.8)
rake (0.8.7)
tzinfo (0.3.23)
Для соответствующего user_id нет предложения where. Но как это исправить?
Rails версия 2.3.8
Надеюсь, кто-нибудь может помочь