From 1c42bf92c03a74543485106ff841477518dae5ea Mon Sep 17 00:00:00 2001 From: Nishanth Vijayan Date: Wed, 28 Sep 2016 18:42:18 +0530 Subject: [PATCH] Link commercialable only if it exists else just display title/name --- .../versions/_object_desc_and_link.html.haml | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/views/admin/versions/_object_desc_and_link.html.haml b/app/views/admin/versions/_object_desc_and_link.html.haml index 07f19002..53f5a22d 100644 --- a/app/views/admin/versions/_object_desc_and_link.html.haml +++ b/app/views/admin/versions/_object_desc_and_link.html.haml @@ -17,18 +17,26 @@ - when 'Commercial' - commercial = current_or_last_object_state(version.item_type, version.item_id) - commercialable = current_or_last_object_state(commercial.commercialable_type, commercial.commercialable_id) + - commercialable_last_version = PaperTrail::Version.where(item_type: commercial.commercialable_type, item_id: commercial.commercialable_id).last - case commercial.commercialable_type - when 'Event' - commercial in event - = link_to (commercialable.try(:title) || 'deleted event'), - admin_conference_program_event_path(conference_id: Conference.find(version.conference_id).short_title, id: commercialable.id) + commercial in + - if commercialable_last_version.item + event + = link_to commercialable.title, + admin_conference_program_event_path(conference_id: Conference.find(version.conference_id).short_title, id: commercialable.id) + - else + = commercialable.title - when 'Venue' commercial in venue - = link_to commercialable.name, - edit_admin_conference_venue_path(conference_id: Conference.find(version.conference_id).short_title, - id: commercialable.id, anchor: 'commercials-content') + - if commercialable_last_version.item + = link_to commercialable.name, + edit_admin_conference_venue_path(conference_id: Conference.find(version.conference_id).short_title, + id: commercialable.id, anchor: 'commercials-content') + - else + = commercialable.name - when 'Conference' = link_to 'commercial',