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.
First part of my question
UPDATE: This part resolved.
For test purposes, I placed a video file under Project/public. And in @lesson.media_file I wrote just a file name, video.webm. But the player can't find the file, player says: Error loading media: File could not be played, and the logs show that video location is presumed to be /courses/2/lessons/video.webm (it is just a route, not a file system path), although it is in Project/public/.
So, how should I be giving a location string in @lesson.media_file so jwplayer is able to find the actual video file?
Second part of my question
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.
What would be your suggestions related to protecting video files?
Thank you very much!