I have a TakeAction model that looks like this:
class TakeAction < ActiveRecord::Base
and a TakeActionNote model that looks like this:
class TakeActionNote < ActiveRecord::Base
Using CanCan, I’m trying to allow the user that owns the take_action
to create and destroy (manage) notes.
I’ve tried defining abilities with a block like this.
can :manage, TakeActionNote do |action, note|
note.take_action.user.id == user.id
I can add notes to the take_action without any problem but when I try
to destroy it I get:
NoMethodError in Take action notesController#33 undefined method
`take_action’ for nil:NilClass
Is there anything I’m missing or doing wrong? Any help is appreciated.