-1

In my application I have following code:

@object.start if can? :start, @object

I searched for it and found that app is using cancan gem, but as a beginner I am not getting what this code does exactly. There is no such a function defined with "start" name.

I am totally stuck on this as I am not getting from where to start and what to search.

Surya
  • 15,703
  • 3
  • 51
  • 74
Vikram
  • 3,171
  • 7
  • 37
  • 67

1 Answers1

1

I do not know how the application is working, but the can? definitely comes from the cancan gem.

You can specify the permissions in the app/models/ability.rb file.

It simply reads the ability file to determine if a user can perform some action or not. These actions correspond directly to the actions you have defined in the controller class.

Cancan has a great wiki at its github repositiory. Also, the screencast by ryan is an excellent place to start off with.

You can also see the screencast here.

Vamsi Krishna
  • 3,742
  • 4
  • 20
  • 45