Stan Blog

學習過程中的一些記錄

新造物件宣告方式

若 board has_many posts,新造物件宣告方式是:

  @post = @boards.posts.build

那 book has_one author,要怎麼宣告?

二種方式皆可

@author = @book.author.build

@author = @book.build_author

Comments

comments powered by Disqus