我有以下关系:
class GroupsNorm < ActiveRecord::Base
attr_accessible :group_name, :file_names
has_many :platformas
end
class Platforma < ActiveRecord::Base
attr_accessible :file_name, :norm_type, :groups_norm_id
belongs_to :groupsnorm
end
在控制台中:
a=Platforma.new(:file_name=>"kkkkk.cel",:groups_norm_id=>9)
a.save
b=GroupsNorm.find(9)
=> #<GroupsNorm id: 9, group_name: "aaaaaa", file_names: "/system/Files/aaaaaa_cel_files...", created_at: "2013-05-20 13:37:14", updated_at: "2013-05-20 13:37:14">
b.platformas
[#<Hgu133a id: 1, groups_norm_id: 9, file_name: "aaa.cel", created_at: "2013-05-20 21:31:05", updated_at: "2013-05-20 21:31:05">, #<Hgu133a id: 2, groups_norm_id: 9, file_name: "kkkkk.cel", created_at: "2013-05-20 21:47:24", updated_at: "2013-05-20 21:47:24">, #<Hgu133a id: 3, groups_norm_id: 9, file_name: "kkkkk.cel",created_at: "2013-05-20 21:54:37", updated_at: "2013-05-20 21:54:37">]
所以,一切都很好,我们的新记录也在那里。但是当我打电话时:
irb(main):011:0> a.groupsnorm
=> nil
为什么它不向我显示具有 id==9 的 GroupsNorm 记录?
提前致谢