has_many 关联关系表单 提交
程序员文章站
2022-07-15 20:04:20
...
class Author
has_many :books
end
class Book
belongs_to :author
end
author = Author.create(:name => "zcy", :book_ids => [1,2,3])
author.books.collect(&:id) => [1,2,3]
has_many :books
end
class Book
belongs_to :author
end
author = Author.create(:name => "zcy", :book_ids => [1,2,3])
author.books.collect(&:id) => [1,2,3]
上一篇: 数组使用will_paginate
下一篇: rails 根据异常显示特定的错误页面