1

Could you help me to solve this ?

I'm creating a management application with to different users :

"User" they are definided in app, that's management person, won't change, and "Student" they are definided in a table that would growing for the next 6 month (now I have maybe 10 students in this table, next month maybe 100) Attribut between users and students are different

I should create an application with backend and frontend

Frontend could be used by user and student Backend could be used only by user if they have "admin" flag

I would use ActiveAdmin for backend But for Frontend i'm lost...

It seems that cancan and devise could solve this, but :

  • Should I create a User model and a Student model, or is there a better way ?
  • Howto manage the connection on the same frontend views(maybe should i create two different views) from two differents tables (users and students) ?
  • Student should receive a "student_role" automatically, howto do this ?

All idea would be greatly appreciated, many thanks to read me !

Nicolas

Nicolas R
  • 55
  • 6

1 Answers1

0

can can + devise is a great way to solve problems like this one,

also i would suggest only one model for the user and a usertype attribute that defines if its a student or a user, for the connections you can create a user controller and a student controller if you only need to show them to specific users and you can use cancan to authorize that like this:

class Ability
  include CanCan::Ability
  def initialize(user)
    if user.usertype=1
      can :read, Student
    elsif user.usertype=2
      can read, User
    end    
  end
end 

your student role can be the usertype = 1 or something

if you need more help ask me.

Rodrigo Zurek
  • 4,555
  • 7
  • 33
  • 45