Update personal_books_helper.rb

add show member method
This commit is contained in:
chiu 2019-11-13 12:24:41 +08:00
parent d53e9a48c7
commit 0d6ab9100c
1 changed files with 5 additions and 2 deletions

View File

@ -1,13 +1,16 @@
module Admin::PersonalBooksHelper 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 '') (book.authors.to_s.blank? ? get_member(book).collect(&:name).join('/') : Nokogiri::HTML(book.authors.to_s).text rescue '')
end end
def get_authors_show(book) def get_authors_show(book)
(book.authors.to_s.blank? ? get_member(book).collect{|member| "<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member.name}'>#{member.name}</a>"}.join('/') : book.authors.to_s rescue '') (book.authors.to_s.blank? ? get_member_show(book) : book.authors.to_s) rescue ''
end end
def get_member(book) def get_member(book)
Array(MemberProfile.find(Array(book).collect(&:member_profile_id))) Array(MemberProfile.find(Array(book).collect(&:member_profile_id)))
end end
def get_member_show(book)
get_member(book).collect{|member| "<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member.name}'>#{member.name}</a>"}.join('/')
end
def get_publisher(book) def get_publisher(book)
book.publisher book.publisher
end end