我正在使用Rails 2.3.8。我有以下数据这个表店:显示表属于belongs_to表的商店数据国家,在国家视图中显示
商店数据库表
ID | country_id | notes
1 | 10 | test
2 | 10 | testing
3 | 12 | tested
在shop.rb
我把belongs_to :country
。
在我国的view.html.erb
中,我希望能够从Shops表中显示相关notes
。在这种情况下,在页面http://localhost:3000/countries/10
,notes
中应该出现Shop1的ID1和ID2。
有人能教我如何做到这一点?非常感谢你。
谢谢奥古斯托。我很抱歉,我只能接受一个答案。所以我会接受拉法尔的回答,因为他先回答了。我仍然很感激。 – Victor 2011-02-15 16:46:44