Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Lesson < ApplicationRecord
- belongs_to :course
- has_one_attached :file
- default_scope -> { order(created_at: :desc) }
- validates :course_id, presence: true
- validates :name, presence: true
- end
- class CreateLessons < ActiveRecord::Migration[5.1]
- def change
- create_table :lessons do |t|
- t.text :name
- t.references :course, foreign_key: true
- t.timestamps
- end
- add_index :lessons, [:course_id, :created_at]
- end
- end
- <div class="signup">
- <h2><%= @lesson.name %></h2>
- <video id="video" controls="true" width="auto" height="auto">
- <source src="<%= url_for(@lesson.file) %>" type='video/mp4'>
- </video>
- </div>
- <script>
- document.getElementById("video").addEventListener("ended", function(){alert("all done")}, true);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement