Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Obed Lorisson
Front End Web Development Techdegree Student 6,151 PointsHelp with ruby on rails project
im doing a personal project it's a video playing web app , just to apply more concepts. the way is work the video file is on a cdn , i use a script tag to include the video on the rails application via an helper method.but there's something that i can't quite figure it out , how to make the show page display the video without refreshing . check out it without the UI.
my code:
module ApplicationHelper
def embed_video(url)
render :partial => 'shared/video', :locals => { :url => url}
end
end
shared/video.html.erb
<script type="text/javascript" src="<%= @video.url %>"></script>
index.html.erb
<h1>Listing videos</h1>
<table>
<thead>
<tr>
<th>Title</th>
<th>group</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% @videos.each do |video| %>
<tr>
<td><%=image_tag video.poster(:medium)%></td>
<td><%= video.title %></td>
<td><%= video.group %></td>
<td><%= link_to 'Show', video_path(video) %></td>
<td><%= link_to 'Edit', edit_video_path(video) %></td>
<td><%= link_to 'Destroy', video, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
show.html.erb <p id="notice"><%= notice %></p>
<div id="video_display">
<%= embed_video @video.url %>
</div>
<p>
<strong>Title:</strong>
<%= @video.title %>
</p>
<p>
<strong>group:</strong>
<%= @video.group %>
</p>
<%= link_to 'Edit', edit_video_path(@video) %> |
<%= link_to 'Back', videos_path %>
1 Answer
John Paul Ashenfelter
1,118 PointsThe video probably needs a player -- you're pulling in the video URL as javascript source.
You could try using something like http://mediaelementjs.com to play the video from the URL
Obed Lorisson
Front End Web Development Techdegree Student 6,151 PointsObed Lorisson
Front End Web Development Techdegree Student 6,151 PointsJohn Paul Ashenfelter Thanks for the comments, i fix it , the issue was instead of using iframe tag , i use java script tag but for one reason it was not working as soon as a change it works fine . thanks for the comment