You can manipulate data before saving it
class User
before_save :do_something
def do_something
// process music_tracks here
end
end
PS: I do not know the purpose of your project, but in general, having
a table of songs referred by id seems a better option to me.
Song 1 => { band => "Kiss", "title" => "Strutter" }
User 1 => [1, 1, 1]
User 2 => [1, 1, 1]
User 3 => [1, 1, 1]
In your case, you will get multiple copies of bloated data spread all
over DB if many users listen to the same song over and over again.
User 1 => { 1 => "Kiss: Strutter",
2 => "Kiss: Strutter",
3 => "Kiss: Strutter" }
User 2 => { 1 => "Kiss: Strutter",
2 => "Kiss: Strutter",
3 => "Kiss: Strutter" }
User 3 => { 1 => "Kiss: Strutter",
2 => "Kiss: Strutter",
3 => "Kiss: Strutter" }
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.