I have a model User which automatically has a Task generated.
I want to lock this task from editing or deleting.
What kind of modifications to my controller do I need to make? Is there an elegant solution, or do I need to check every time there’s an edit/destroy if it’s the task in question.
There is no elegant solution as far as I am aware, you would have to check every time in the controller, but this is simple by defining this method in your controller:
Then you can call this method as a
before_filterfor those actions you care about. By returningnil(that’s whatreturndoes), thebefore_filterwill halt and the action will not be executed.