Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access 'can?' method from within cell?

I'm using cancan and cells gems in my ruby-on-rails project. How to access can? method from within cell? Thanks.

like image 750
Максим Дмитриев Avatar asked Apr 05 '11 03:04

Максим Дмитриев


1 Answers

I've had to do exactly this. Try

class MyCell < Cell::Rails

  include CanCan::ControllerAdditions

end                                        

If you're also using Devise, I had to do this:

class MyCell < Cell::Rails

  include CanCan::ControllerAdditions
  include Devise::Controllers::Helpers
  Devise::Controllers::Helpers.define_helpers(Devise::Mapping.new(:user, {}))

end                                        

#define_helpers will add helper methods such as current_user and user_signed_in? to the cell.

like image 86
qnm Avatar answered Nov 15 '22 16:11

qnm