[code] map.resources :account_types, :has_many => :accounts
[/code]
是简短写法,等价于
[code]map.resources :account_types do |account_type|
account_type.resources :accounts
end[/code]
且慢,有一点变化要注意:
最后生成的是 account_type_accouts_path 而不是 account_path, 如果要还原成1.2的样子,需要这么写:
[code]map.resources :account_types do |account_type|
account_type.resources :accounts, :name_prefix => nil
end[/code]
[/code]
是简短写法,等价于
[code]map.resources :account_types do |account_type|
account_type.resources :accounts
end[/code]
且慢,有一点变化要注意:
最后生成的是 account_type_accouts_path 而不是 account_path, 如果要还原成1.2的样子,需要这么写:
[code]map.resources :account_types do |account_type|
account_type.resources :accounts, :name_prefix => nil
end[/code]