开发者

Generating dynamic playlists using user preference

I'm trying to build a web app using ruby on rails. In this project users can search through the songs on our website and can create they're own playlists . The App also has to generate dynamic playlists based on the users likes and dislikes . This is my problem , i can't find a simple and efficient solution that doesn't overwhelm my database . So if anyone can tell me some basic principles to this issue , about开发者_如何学Python designing the models or a very elegant solution ( any little info will help me a lot )

Thank you


You could link the Song with a Vote model which would be linked with the User model. The Vote model can have a like and dislike boolean column for example. This way you could register a like or dislike vote for each user per song.

There could potentially be a lot of rows in all these tables but I don't understand what you mean with "overwhelm". As long as the structure is clear it doesn't matter how much data you have there, that's what the database is for, no?

class User < ActiveRecord::Base
  has_many :votes
end

class Vote < ActiveRecord::Base
  belongs_to :user
  belongs_to :song
end

class Song < ActiveRecord::Base
  has_many :votes
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜