title: Linking to a video file for jwplayer in Rails
body: <p>I was building a site for presenting video courses and text explanations. My Lesson model's show page include jwplayer. Also, one of the lesson's attributes --media_file, -- contains a path to an actual video file for the current lesson.</p>
  
  <p><strong>First part of my question</strong></p>
  
  <p>UPDATE: This part resolved.</p>
  
  <p>For test purposes, I placed a video file under Project/public. And in @lesson.media_file I wrote just a file name, <em>video.webm</em>. But the player can't find the file, player says: <em>Error loading media: File could not be played</em>, and the logs show that video location is presumed to be <em>/courses/2/lessons/video.webm</em> (it is just a route, not a file system path), although it is in Project/public/.</p>
  
  <p>So, how should I be giving a location string in @lesson.media_file so jwplayer is able to find the actual video file?</p>
  
  <p><strong>Second part of my question</strong></p>
  
  <p>In above part of my test, when I put the video under /public, I just wanted to test the video embedding in Rails. But for real application, I'd like to restrict video preview, so video should be accessible only by visiting lessons show route, and video files shouldn't be publicly accessible by themselves, unlike a resource under /public. </p>
  
  <p>What would be your suggestions related to protecting video files?</p>
  
  <p>Thank you very much!</p>