Definition of roles in Wordpress style

0

I am planning the architecture of a personal project to be implemented using Rails. In it, I would like it to be possible to easily modify user access rules, as is done in wordpress. I know there is the cancan to do this, but I believe it would not serve my need. It is a service-oriented application. Each user will only be allowed access to certain services. I thought of implementing a solution specific to that need that would allow the application administrator to easily modify users' access permissions through an administrative interface. Could someone tell me a solution to this?

    
asked by anonymous 03.12.2014 / 13:07

1 answer

0

Well, there's no secret, it's the basics, step-by-step:

  • List the users and their role (admin, guest, student, etc.)
  • Clicking on the user can update their function.
  • When visiting some page check if the user has the permission to view the page.
  • The user template must have a "role" field that will be checked for the user to view or use something that requires authorization.

    For example in your view you could do the following:

    <% if is_admin(@user) %>
      <%= link_to "Edit", edit_post_path(@post) %>
    <% end %>
    

    Depending on the required complexity you can increase what you need.

        
    08.12.2014 / 22:08