Displaying 1 result from an estimated 1 matches for "authors_control".
2006 Apr 05
3
CRUD pattern for has_many relationships (forms containing collections)?
...%= link_to_remote "Add book", :url => {:action => "add_book"}
:update => "books_list" %>
<div id="books_list">
<%= render :partial => "books/book", :collection => author.books %>
</div>
...and in authors_controller.rb
def new
session[:books] = Array.new
end
def add_book
book = Book.new(:title => "untitled")
book.id = -session[:books].size
session[:books] << book
render :partial => "books/book", :collection => session[:books]
end
def create
# code omm...