Access to the video on the condition

Tell me please how to Rails technology is implemented access to the video on the condition? For example a website where people can view the video, paying only money for it. That is, membership in such lynda.com.

There is a plugin for that or is it all written from scratch?

not from scratch , but you have to know what you are doing, read about it here

http://apidock.com/rails/ActionController/Streaming/send_file