Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Advice about "best" user setup


  • Please log in to reply
2 replies to this topic

#1 magnus

magnus

    Passenger

  • Members
  • 5 posts

Posted 23 September 2013 - 02:39 PM

Hello

I'm building my first RoR site. And in short it is a site there you can "sign up" to participate in courses. There will be two kind of users that need to sign up / log in: instructors and admin.

 

Admin is me ;)  - and I will approve all instructors before the can log in. The ordinary visitor who would like to participate in a course do not need to sign up (he will be "approved" (and contacted) by the instructor).

 

Each instructor can only add new courses (in their account) and edit courses he have created. And, I'm planning to use Devise.

 

So the question is: should I create two user models (instructors and admin), or just one and assign different roles (a checkbox(?) for admins). And - maybe it is also better to have the ordinary users sign up (for future proofing??)?

 

Best regards, Magnus



#2 stevieing

stevieing

    Dispatcher

  • Members
  • 40 posts

Posted 23 September 2013 - 03:08 PM

You can use single table inheritance i.e. have a user model and then an Instructors and Admin models that inherit from User.

 

Ryan Bates has also done a Screencast on authorisation http://railscasts.co...-scratch-part-1 which I have used for different types of users.

 

You could also use an authorisation gem such as Can Can.

 

Steve.



#3 magnus

magnus

    Passenger

  • Members
  • 5 posts

Posted 24 September 2013 - 04:15 PM

Thanks Steve.

Will read up on single table inheritance ;) Great tips about Ryan's screencast (and Cancan).

 

Best regards,

Magnus






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users