ruby on rails - Features implementation issue -


i have application i'm working on , it's video streaming app , feature i'm trying implement playlist(collection of videos user see unique name ).

in associations :

 user => has_many playlists,  video => belongs_to playlists,  playlist => belongs_to user 

ps. in app , general user cannot create videos admin .

after created playlist , user should able add video playlist via button . if i'm correct playlist should array .and there's function add _to _playlist retrieve video video_id , push array , return final playlist.

my main issue is, i'm pretty confused on how implementation.any gladly appreciate.

if using activerecord , want associate arrays instances of model, should use serialize class method.

from the docs:

class user < activerecord::base   serialize :preferences end  user = user.create(preferences: { "background" => "black", "display" => large }) user.find(user.id).preferences # => { "background" => "black", "display" => large } 

that example uses hash, serialize permits arrays. if want restrict attribute arrays only, can so:

serialize :attr, array 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -