From 0d6ab9100c166c1e84f2b6668d6a43e77d50482a Mon Sep 17 00:00:00 2001 From: chiu Date: Wed, 13 Nov 2019 12:24:41 +0800 Subject: [PATCH 1/2] Update personal_books_helper.rb add show member method --- app/helpers/admin/personal_books_helper.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/helpers/admin/personal_books_helper.rb b/app/helpers/admin/personal_books_helper.rb index 87e6daa..622309b 100644 --- a/app/helpers/admin/personal_books_helper.rb +++ b/app/helpers/admin/personal_books_helper.rb @@ -1,13 +1,16 @@ module Admin::PersonalBooksHelper - def get_authors_text(book) + def get_authors_text(book) (book.authors.to_s.blank? ? get_member(book).collect(&:name).join('/') : Nokogiri::HTML(book.authors.to_s).text rescue '') end def get_authors_show(book) - (book.authors.to_s.blank? ? get_member(book).collect{|member| "#{member.name}"}.join('/') : book.authors.to_s rescue '') + (book.authors.to_s.blank? ? get_member_show(book) : book.authors.to_s) rescue '' end def get_member(book) Array(MemberProfile.find(Array(book).collect(&:member_profile_id))) end + def get_member_show(book) + get_member(book).collect{|member| "#{member.name}"}.join('/') + end def get_publisher(book) book.publisher end From 7d0194e620b7ee50b50b9689b67d7b8e68be0f34 Mon Sep 17 00:00:00 2001 From: chiu Date: Wed, 13 Nov 2019 12:26:30 +0800 Subject: [PATCH 2/2] Update _writing_book.html.erb fix the problem of showing author --- app/views/admin/books/_writing_book.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/books/_writing_book.html.erb b/app/views/admin/books/_writing_book.html.erb index 47dcd36..2b5065e 100644 --- a/app/views/admin/books/_writing_book.html.erb +++ b/app/views/admin/books/_writing_book.html.erb @@ -12,6 +12,6 @@ - <%= writing_book.member_profile.name rescue "" %> + <%= get_member_show(writing_book).html_safe %> <% end %>