Skip to content

How to: Integrate with CanCan

Leonardo Crauss Daronco edited this page Jun 7, 2014 · 2 revisions

CanCan is a gem used to authorize resources in Rails. BigbluebuttonRails doesn't use CanCan internally yet, but you can still use CanCan to authorize the resources added by BigbluebuttonRails in your application, without having to reimplement the actions in these controllers.

Controllers

To set up authorization with CanCan, first learn How to: Inherit controllers. Inheriting controllers you will be able to add (before-)filters to these controllers and authorize all the actions in BigbluebuttonRails.

Example:

class CustomBigbluebuttonRoomsController < Bigbluebutton::RoomsController
  load_and_authorize_resource :find_by => :param, :class => "BigbluebuttonRoom"
  ...
end

class CustomBigbluebuttonRecordingsController < Bigbluebutton::RecordingsController
  load_and_authorize_resource :find_by => :recordid, :class => "BigbluebuttonRecording"
  ...
end

You can use this strategy for any of the controllers in BigbluebuttonRails. To see the controllers available just check the folder app/controllers/bigbluebutton.

Views

It is always recommended that you implement your own views over the ones provided by BigbluebuttonRails (see How to: Generators). Once you've done it, you can safely use CanCan's view helpers (e.g. can?) in these views.

Example application

Mconf-Web is the most complete implementation of an application that uses this gem (that we know of), so you can always use it as an example. The version of Mconf-Web curerntly in the branch branch-v2 uses CanCan and it is well integrated with BigbluebuttonRails.