Hi everyone, i am using roles in my project for admin and author and so on... This is my code " ROLES = %w[admin moderator author] def roles=(roles) self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum end def roles ROLES.reject { |r| ((roles_mask || 0) & 2**ROLES.index(r)).zero? } end def role?(role) roles.include? role.to_s end end " But if somebody wants to sign in he can choose between admin, moderator, author by himself. He has to be automatically author. Is there a way to fix that problem? Thanks -- 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.
Frederick Cheung
2010-Jun-14 16:07 UTC
[Rails] Re: Using Roles but don´t want to show them
On Jun 14, 4:59 pm, Mark <mjonas.m...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > But if somebody wants to sign in he can choose between admin, > moderator, author by himself. He has to be automatically author. > Is there a way to fix that problem? >Don''t put a role popup on the form ? ( & disallow mass assignment for the attribute) Fred> Thanks-- 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.
Thank you for your answer but i don''t understand what you mean. I don''t have a popup on the form. In my view there are in the sign in form the three checkboxes []admin []moderator []author So there you can choose what function you want to have. But no one else has to be admin. Everybody has to be author. So I just want du show one checkbox "author". But i can not delete admin and moderator because my admin account hasn''t got the admin functions if i delete it. You know what i mean? So i just want to fade out the other oppertunities. Thanks very much On 14 Jun., 18:07, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jun 14, 4:59 pm, Mark <mjonas.m...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > But if somebody wants to sign in he can choose between admin, > > moderator, author by himself. He has to be automatically author. > > Is there a way to fix that problem? > > Don''t put a role popup on the form ? ( & disallow mass assignment for > the attribute) > > Fred > > > > > Thanks-- 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.
On 17 June 2010 21:51, Mark <mjonas.mail-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Thank you for your answer but i don''t understand what you mean. > I don''t have a popup on the form. > > In my view there are in the sign in form the three checkboxes > > []admin > []moderator > []author > > So there you can choose what function you want to have. But no one > else has to be admin. Everybody has to be author. So I just want du > show one checkbox "author". But i can not delete admin and moderator > because my admin account hasn''t got the admin functions if i delete > it. > You know what i mean? > > So i just want to fade out the other oppertunities.Could you not top post please, it is easier to follow the thread if comments are inserted into the previous email. Thanks Why not just do not put the options on the sign in form? If it always has to be author there is no need to put it on the form at all. This does not mean that you have to do away with the roles, just do not give the option to set it on the signup form. Presumably you have an alternative method of setting up admin and moderator roles. Colin> > Thanks very much > > > On 14 Jun., 18:07, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On Jun 14, 4:59 pm, Mark <mjonas.m...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> >> >> > But if somebody wants to sign in he can choose between admin, >> > moderator, author by himself. He has to be automatically author. >> > Is there a way to fix that problem? >> >> Don''t put a role popup on the form ? ( & disallow mass assignment for >> the attribute) >> >> Fred >> >> >> >> > Thanks > > -- > 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. > >-- 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.