From 71f750ca9ddb2e769cc87a73a7eed1761a6d2c3b Mon Sep 17 00:00:00 2001 From: lalo Date: Thu, 9 May 2019 12:49:10 +0200 Subject: [PATCH] Refactor embedded_video_code method to use it with other models --- app/helpers/embed_videos_helper.rb | 6 +++--- app/views/legislation/proposals/show.html.erb | 2 +- app/views/proposals/_info.html.erb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/embed_videos_helper.rb b/app/helpers/embed_videos_helper.rb index 645376525..a786e4b15 100644 --- a/app/helpers/embed_videos_helper.rb +++ b/app/helpers/embed_videos_helper.rb @@ -3,9 +3,9 @@ module EmbedVideosHelper VIMEO_REGEX = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/ YOUTUBE_REGEX = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/ - def embedded_video_code - link = @proposal.video_url - title = t("proposals.show.embed_video_title", proposal: @proposal.title) + def embedded_video_code(resource) + link = resource.video_url + title = t("proposals.show.embed_video_title", proposal: resource.title) if link =~ /vimeo.*/ server = "Vimeo" elsif link =~ /youtu*.*/ diff --git a/app/views/legislation/proposals/show.html.erb b/app/views/legislation/proposals/show.html.erb index 7d8d18687..42d5d416c 100644 --- a/app/views/legislation/proposals/show.html.erb +++ b/app/views/legislation/proposals/show.html.erb @@ -52,7 +52,7 @@ <% if @proposal.video_url.present? %>
-
+
<% end %> diff --git a/app/views/proposals/_info.html.erb b/app/views/proposals/_info.html.erb index 79e1316e6..55694638a 100644 --- a/app/views/proposals/_info.html.erb +++ b/app/views/proposals/_info.html.erb @@ -29,7 +29,7 @@ <% if @proposal.video_url.present? %>
-
+
<% end %>