Hello, I''m working on my first simple Rails app in which users submit sport "tweets" (e.g. "tennis, squash") and the server matches them up with partners. The server will return you a list of SportMatches based on similar tweets and you have different options (e.g. email, SMS) to reply back to someone''s tweet and accept him/her as partner. Initially, the modeling was straight forward since: User has_many SportTweets and SportTweet belongs to User. Notifications were simply part of the User, or they could have been modeled as a 1-to-1 relationship to User. My business requirements changed a little, as now I have anonymous users who can also post SportTweets. Because they don''t have an account/profile, they must also submit notifications (e.g. email, SMS) with the tweet. I don''t know how to model this the Rails way. SportTweets are now either anonymous, or authenticated-user-posted (AUP). So, now, my SportTweets table will have the following columns: - type: either "anonymous" or "AUP" - user_id: only for AUP - notifications_id: only for anonymous - sports: for all - post_date: for all - post_location: for all - etc. There would be a Notifications table. A notification record would belong either to a User, or to a SportsTweet. I guess I would model this with polymorphic associations. That just doesn''t look like the Rails way. Did anyone come across a similar problem? How did you solve it? Thanks, T -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 11, 2:48 pm, Mr_Tibs <tiberiu.mo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I''m working on my first simple Rails app in which users submit sport > "tweets" (e.g. "tennis, squash") and the server matches them up with > partners. The server will return you a list of SportMatches based on > similar tweets and you have different options (e.g. email, SMS) to > reply back to someone''s tweet and accept him/her as partner. > Initially, the modeling was straight forward since: User has_many > SportTweets and SportTweet belongs to User. Notifications were simply > part of the User, or they could have been modeled as a 1-to-1 > relationship to User. > > My business requirements changed a little, as now I have anonymous > users who can also post SportTweets. Because they don''t have an > account/profile, they must also submit notifications (e.g. email, SMS) > with the tweet. I don''t know how to model this the Rails way. > SportTweets are now either anonymous, or authenticated-user-posted > (AUP). So, now, my SportTweets table will have the following columns: > - type: either "anonymous" or "AUP" > - user_id: only for AUP > - notifications_id: only for anonymous > - sports: for all > - post_date: for all > - post_location: for all > - etc. > > There would be a Notifications table. A notification record would > belong either to a User, or to a SportsTweet. I guess I would model > this with polymorphic associations. > > That just doesn''t look like the Rails way. Did anyone come across a > similar problem? How did you solve it?Is there a particular reason for storing notifications separately? By that I mean that it seems likely that authenticated users will *also* have SMS / email / etc. I''d typically just borrow the existing User machinery but add in a flag ("anonymous", for instance) that skips the registration parts. --Matt Jones -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hey Matt, Thanks for the suggestion. I found it in "The Rails 3 Way" - chapter 9: STI tables. Regards, T On Dec 12, 8:13 am, Matt Jones <al2o...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 11, 2:48 pm, Mr_Tibs <tiberiu.mo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > Hello, > > > I''m working on my first simple Rails app in which users submit sport > > "tweets" (e.g. "tennis, squash") and the server matches them up with > > partners. The server will return you a list of SportMatches based on > > similar tweets and you have different options (e.g. email, SMS) to > > reply back to someone''s tweet and accept him/her as partner. > > Initially, the modeling was straight forward since:Userhas_many > > SportTweets and SportTweet belongs toUser. Notifications were simply > > part of theUser, or they could have been modeled as a 1-to-1 > > relationship toUser. > > > My business requirements changed a little, as now I haveanonymous > > users who can also post SportTweets. Because they don''t have an > > account/profile, they must also submit notifications (e.g. email, SMS) > > with the tweet. I don''t know how to model this the Rails way. > > SportTweets are now eitheranonymous, or authenticated-user-posted > > (AUP). So, now, my SportTweets table will have the following columns: > > - type: either "anonymous" or "AUP" > > - user_id: only for AUP > > - notifications_id: only foranonymous > > - sports: for all > > - post_date: for all > > - post_location: for all > > - etc. > > > There would be a Notifications table. A notification record would > > belong either to aUser, or to a SportsTweet. I guess I would model > > this with polymorphic associations. > > > That just doesn''t look like the Rails way. Did anyone come across a > > similar problem? How did you solve it? > > Is there a particular reason for storing notifications separately? By > that I mean that it seems likely that authenticated users will *also* > have SMS / email / etc. I''d typically just borrow the existingUser > machinery but add in a flag ("anonymous", for instance) that skips the > registration parts. > > --Matt Jones-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.