Marcelo de Moraes Serpa
2008-Jul-21 23:12 UTC
Meaningless REST resources for n:n relationships
Hello all, I''m designing a Rails application that has a Group resource that habtm Permissions. Since I''m following the RESTful pattern, I thought on creating a GroupsPermissions (via Group has_many Permissions :through => GroupsPermissions in the Group model) resource, even thought it doesn''t map to anything concrete (such as Friendship or any other relathinship between two entities). My question is: Is it okay to sometimes create these kind of meaningless resources so that you are able to CRUD them in a RESTful way, instead of creating more actions into the Group and Permissions models? Or is there a better way to do that I might not be aware of? Thanks in advance! Marcelo. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Marcelo de Moraes Serpa
2008-Jul-22 01:52 UTC
Re: Meaningless REST resources for n:n relationships
Ok, already solved it. It happened that it wasn''t a "meaningless" association. Some guys @ #rubyonrails helped me come into a conclusion that Groups vs Permissions Authorization. Thanks goes to dblack and life @ #rubyonrails. The rationale behind using Group has_many Permissions :through => Authorization is that of clean code and design. Since I''m following the RESTful design, I might take advantage of this "controller design pattern" to reduce code and keep things DRY and simple. Instead of creating methods to add permissions to manage the group vs permission relationship in the Group model, I can just use the AuthorizationsController REST methods. Thanks, Marcelo. On Mon, Jul 21, 2008 at 8:12 PM, Marcelo de Moraes Serpa < celoserpa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello all, > > I''m designing a Rails application that has a Group resource that habtm > Permissions. > > Since I''m following the RESTful pattern, I thought on creating a > GroupsPermissions (via Group > has_many Permissions :through => GroupsPermissions in the Group model) > resource, even thought it doesn''t map to anything concrete (such as > Friendship or any other relathinship > between two entities). > > My question is: Is it okay to sometimes create these kind of meaningless > resources so that you are able to CRUD them in a RESTful way, instead of > creating more actions into the Group and Permissions models? Or is there a > better way to do that I might not be aware of? > > Thanks in advance! > > Marcelo. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Marcelo de Moraes Serpa
2008-Jul-22 01:52 UTC
Re: Meaningless REST resources for n:n relationships
Ops, I meant lifo not life for the username of the guy who helped me at the channel. Sorry. On Mon, Jul 21, 2008 at 10:52 PM, Marcelo de Moraes Serpa < celoserpa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok, already solved it. > > It happened that it wasn''t a "meaningless" association. Some guys @ > #rubyonrails helped me come into a conclusion that Groups vs Permissions > Authorization. Thanks goes to dblack and life @ #rubyonrails. > > The rationale behind using Group has_many Permissions :through => > Authorization is that of clean code and design. Since I''m following the > RESTful design, I might take advantage of this "controller design pattern" > to reduce code and keep things DRY and simple. Instead of creating methods > to add permissions to manage the group vs permission relationship in the > Group model, I can just use the AuthorizationsController REST methods. > > Thanks, > > Marcelo. > > > > > > On Mon, Jul 21, 2008 at 8:12 PM, Marcelo de Moraes Serpa < > celoserpa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hello all, >> >> I''m designing a Rails application that has a Group resource that habtm >> Permissions. >> >> Since I''m following the RESTful pattern, I thought on creating a >> GroupsPermissions (via Group >> has_many Permissions :through => GroupsPermissions in the Group model) >> resource, even thought it doesn''t map to anything concrete (such as >> Friendship or any other relathinship >> between two entities). >> >> My question is: Is it okay to sometimes create these kind of meaningless >> resources so that you are able to CRUD them in a RESTful way, instead of >> creating more actions into the Group and Permissions models? Or is there a >> better way to do that I might not be aware of? >> >> Thanks in advance! >> >> Marcelo. >> >> >> >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---