I have 3 models one
Customer Book Book_Managers
id id id
first description customer_id
last book_manager_id visible
email
password
When the customer goes at customer#edit it then render the form books and book_managers into one form
In my bookController I have the following to create a book and book_manager
class BooksController < ApplicationController
def create
@customer = current_customer
@book = @customer.book_managers.build(:visible => "true")
@book = @customer.book_managers.first.books.build(:description => "2012")
end
end
But then it tell me there is missing template. I am also only using a simple form_for. What i am doing wrong? I believe I should be using accepts_nested_attributes_for but any one has a good tutorial for this??
Update: In regard to the railcasts here my relationship and see if it make sense?
Customer
has_many :book_managers
has_many :books, :through => :book_managers
accepts_nested_attributes_for :book_manager
Book
belongs_to :book_manager
def customer
book_manager.customer
end
Book_Manager
belongs_to :customer
has_many :books
accepts_nested_attributes_for :book