简体   繁体   中英

Create Wistia model in Ruby on Rails

I am building currently an web app where the admin will be able to post a title with a description and a link / embedded form of Wistia Video Player.

Currently my setup is:

  • Welcome Page
  • Dashboard Page with Dashboard Controller (here only the admin will be able to post, edit things, all other users can only watch/comment)

How do i create a model for this? Normally i would create a model like this:

rails g model Video title:string description:text 

But how do i implement the Wistia Video Player, so that everytime the Admin creates a new post, he will be able to link/embedded a new video?

If I got you right then you want a permissions system that gives a user with the role "Administrator" the ability to create a new post with an embedded video? Normal "users" shouldn't be able to do this, right? Do you already have a "Login system" or something familiar? If not you should create a permissions system with sessions and stuff like that. (keyword: has_secure_password, BCrypt and sessions). After creating the system you could just use a before_action in your video controller or however you called it. With the before action you could simply check if the user that is logged in has the role "Administrator". If you only want to forbid embedding videos then just check the post before saving it to your table in the database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM