0

I am wondering what my best approach to do what I want to achieve. I have completed the railcasts at http://railscasts.com/episodes/196-nested-model-form-revised but a bit unsured on how to proceed

Here my models

Customer
Book
BookManager

A customer has_many book_manager, in which book_manager has_many books. I am following the nested relationship provided by the railcasts but here my model

Customer       BookManager         Book
ID             Customer_ID         ID
First          Book_ID             Description
Last           isVisible
               isDeleted

The idea is the customer create a new book_description and also set if its visible, and if the customer delete the item, then i want to hide it but also set in the database the book_manager associated with it that its deleted, but not removed at all in the database.

Thanks any suggestion or idea on how to proceed is appreciated

4

1 に答える 1

0

Book は BookManger と 1 対 1 の関係にあるように見えるので、この 2 つを組み合わせることを検討してください。そうでない限り、私は関係を誤解しています。それは物事をより簡単にするかもしれません。

非表示の処理に関しては、コントローラー/ビューで既にあるフィールドにアクセスすることで簡単に実行できます: isVisible および isDeleted。次のようなスコープをモデルに作成することもできます。

class BookManager
  scope :active, where(["isVisible = ? AND isDeleted = ?", true, false])   
于 2012-08-06T19:10:49.323 に答える