Hello all, We are converting our application so that user-generated content such as votes, photos, users, comments, etc are all disabled instead of deleted. This serves us better as administrators of the site as well as fits into a UI redesign coming later that will include undo functionality. The question I have is would it be better to place the active=true condition part of all my associations I already have in place (little work), or do I strip my associations down to barebones and build named_scopes for my "active" state, and any other states? The problem here is I would need to append nearly all calls to photo.votes, photo.comments, project.photos, project.votes, etc with .active (much more work). Which is the better method in the long run? Thanks guys. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Makes sense just to add conditions to the associations so: class Photo has_many :votes, :conditions => [''active = ? '', true] end I presume this is what you''re planning on doing at the moment? Less work and I doubt the scope would perform noticeably better (if at all) ? Why not try both methods and check the speed of each query? On Apr 15, 9:58 pm, Bryan Corey <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello all, > > We are converting our application so that user-generated content such as > votes, photos, users, comments, etc are all disabled instead of deleted. > This serves us better as administrators of the site as well as fits into > a UI redesign coming later that will include undo functionality. The > question I have is would it be better to place the active=true condition > part of all my associations I already have in place (little work), or do > I strip my associations down to barebones and build named_scopes for my > "active" state, and any other states? The problem here is I would need > to append nearly all calls to photo.votes, photo.comments, > project.photos, project.votes, etc with .active (much more work). > > Which is the better method in the long run? Thanks guys. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''d suggest that you take a look at acts_as_paranoid for some ideas to implement this without scattering checks all over the application. Also dig around for a discussion on re-implementing acts_as_paranoid with default_scope. --Matt Jones On Apr 15, 4:58 pm, Bryan Corey <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello all, > > We are converting our application so that user-generated content such as > votes, photos, users, comments, etc are all disabled instead of deleted. > This serves us better as administrators of the site as well as fits into > a UI redesign coming later that will include undo functionality. The > question I have is would it be better to place the active=true condition > part of all my associations I already have in place (little work), or do > I strip my associations down to barebones and build named_scopes for my > "active" state, and any other states? The problem here is I would need > to append nearly all calls to photo.votes, photo.comments, > project.photos, project.votes, etc with .active (much more work). > > Which is the better method in the long run? Thanks guys. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---