Bergrebell / CyberCoach

1 stars 1 forks source link

create a rails model SportSession and SessionPartcipants #32

Closed lexruee closed 9 years ago

lexruee commented 9 years ago

Create a rails model SessionParticipants and SportSession.

SessionParticipants models a group of users that are participating in a sport session.

sport_session 1

wanze commented 9 years ago

Should we rename "SessionParticipants" to "SportSessionParticipant"? Because of consistency :)

wanze commented 9 years ago

Hi Sveta, sorry I did not realize that you assigned yourself to this task. Have you done anything? :)

I have pushed a new branch implementing these models. I'm using the built in "Single Table Inheritance" support of ActiveRecord: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#label-Single+table+inheritance

This test does nothing at all for the moment, but shows some examples how the models are related: https://github.com/Bergrebell/CyberCoach/blob/SportSession_Single_Table_Inheritance/test/models/sport_session_test.rb

I really think that with this model we have a simple solution to create the SportEvents and store the participants. The data of the event is fully stored on the CyberCoach service. If we set the created entry to "public", each user participating can grab the details, thus we don't need to create the sport entry for each user :)

Cheers

svetakrasikova commented 9 years ago

Hi Stefan,

No, I haven't done much :) I've been looking at what Alex has done, and just started on this half an hour ago. In any case, it's been instructive.

I'll look at what you've done right away. I am sure it's amazingly cool and elegant, judging from what you are saying. I may need to bother you with some questions later on :)

Cheers, Sveta

26 Oct 2014, в 21:06, Stefan Wanzenried notifications@github.com написал(а):

Hi Sveta, sorry I did not realize that you assigned yourself to this task. Have you done anything? :)

I have pushed a new branch implementing these models. I'm using the built in "Single Table Inheritance" support of ActiveRecord: http://api.rubyonrails.org/classes/ActiveRecord/Base.html#label-Single+table+inheritance

This test does nothing at all for the moment, but shows some examples how the models are related: https://github.com/Bergrebell/CyberCoach/blob/SportSession_Single_Table_Inheritance/test/models/sport_session_test.rb

I really think that with this model we have a simple solution to create the SportEvents and store the participants. The data of the event is fully stored on the CyberCoach service. If we set the created entry to "public", each user participating can grab the details, thus we don't need to create the sport entry for each user :)

Cheers

— Reply to this email directly or view it on GitHub.

svetakrasikova commented 9 years ago

@wanze Stefan, SportSessionTest is very helpful to understand the models, thanks. Single table inheritance is "switched on" because you added the field 'type' to SportSession, right?

wanze commented 9 years ago

@svetakrasikova Yep exactly :) This is a very cool feature of rails, basically all Sports do have their own object, but the data is stored in the same table. ActiveRecord handles this automagically for us.