From d4799d671183a2fb3225399d997377406d5273e5 Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Thu, 3 Jul 2014 22:34:44 +0800 Subject: [PATCH] fixes for form --- app/models/book.rb | 2 ++ app/models/book_author_type.rb | 3 ++- app/views/admin/books/_form.html.erb | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/book.rb b/app/models/book.rb index 6dd04c5..6ecb312 100644 --- a/app/models/book.rb +++ b/app/models/book.rb @@ -31,6 +31,8 @@ class Book has_and_belongs_to_many :book_authors accepts_nested_attributes_for :book_authors + has_and_belongs_to_many :book_author_types + belongs_to :book_type before_validation :add_http diff --git a/app/models/book_author_type.rb b/app/models/book_author_type.rb index 8374faf..5086709 100644 --- a/app/models/book_author_type.rb +++ b/app/models/book_author_type.rb @@ -6,6 +6,7 @@ class BookAuthorType field :key, type: String field :title, type: String, localize: true - + + has_and_belongs_to_many :books has_and_belongs_to_many :book_authors end diff --git a/app/views/admin/books/_form.html.erb b/app/views/admin/books/_form.html.erb index 68e32f4..ce923f6 100644 --- a/app/views/admin/books/_form.html.erb +++ b/app/views/admin/books/_form.html.erb @@ -43,7 +43,6 @@ <%= content_tag :label,:class => "checkbox inline" do -%> <%= check_box_tag 'book[book_author_type_ids][]', author_type.id, @book.book_author_type_ids.include?(author_type.id)%> <%= author_type.title %> - <%= hidden_field_tag 'book[book_author_type_ids][]', '' %> <% end %> <% end %>