I''m writing a wiki-based website from scratch and would like some suggestions on the best way to deal with this common situation. A page can be edited by a logged-in and registered user or by an anonymous visitor. If a user edits the page, the model object representing the edit is associated with a user via a user_id foreign key. But if an anonymous visitor can edit the page too, what''s the best way to model this? One idea I''m entertaining is to make a polymorphic relationship between the edit or page version and two different classes: a User class and an AnonymousVisitor class. But I''m not sure. Thanks in advance for your tips and suggestions. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I forgot to mention the requirement that if an anonymous visitor edits a page, their IP address is recorded. On Feb 23, 10:58 am, Daniel Choi <dhc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m writing a wiki-based website from scratch and would like some > suggestions on the best way to deal with this common situation. A page > can be edited by a logged-in and registered user or by an anonymous > visitor. If a user edits the page, the model object representing the > edit is associated with a user via a user_id foreign key. But if an > anonymous visitor can edit the page too, what''s the best way to model > this? > > One idea I''m entertaining is to make a polymorphic relationship > between the edit or page version and two different classes: a User > class and an AnonymousVisitor class. But I''m not sure. > > Thanks in advance for your tips and suggestions.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Create a single row in the user table to represent the anonymous user, and associate the IP address with the edit instead of with the user. That way you don''t clutter your database with anonymous users but you still retain the IP for each edit. On Mon, Feb 23, 2009 at 8:00 AM, Daniel Choi <dhchoi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I forgot to mention the requirement that if an anonymous visitor edits > a page, their IP address is recorded. > > On Feb 23, 10:58 am, Daniel Choi <dhc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I''m writing a wiki-based website from scratch and would like some >> suggestions on the best way to deal with this common situation. A page >> can be edited by a logged-in and registered user or by an anonymous >> visitor. If a user edits the page, the model object representing the >> edit is associated with a user via a user_id foreign key. But if an >> anonymous visitor can edit the page too, what''s the best way to model >> this? >> >> One idea I''m entertaining is to make a polymorphic relationship >> between the edit or page version and two different classes: a User >> class and an AnonymousVisitor class. But I''m not sure. >> >> Thanks in advance for your tips and suggestions.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Sarah. On Feb 23, 12:36 pm, Sarah Mei <sarah...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Create a single row in the user table to represent the anonymous user, > and associate the IP address with the edit instead of with the user. > That way you don''t clutter your database with anonymous users but you > still retain the IP for each edit. > > On Mon, Feb 23, 2009 at 8:00 AM, Daniel Choi <dhc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I forgot to mention the requirement that if an anonymous visitor edits > > a page, their IP address is recorded. > > > On Feb 23, 10:58 am, Daniel Choi <dhc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> I''m writing a wiki-based website from scratch and would like some > >> suggestions on the best way to deal with this common situation. A page > >> can be edited by a logged-in and registered user or by an anonymous > >> visitor. If a user edits the page, the model object representing the > >> edit is associated with a user via a user_id foreign key. But if an > >> anonymous visitor can edit the page too, what''s the best way to model > >> this? > > >> One idea I''m entertaining is to make a polymorphic relationship > >> between the edit or page version and two different classes: a User > >> class and an AnonymousVisitor class. But I''m not sure. > > >> Thanks in advance for your tips and suggestions.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---