Topic: how to integrate dynamic-attr-accessible with cancan

I am using cancan in my project. load_and_authorize_resource will do following to the create action

@project =
current_ability.attributes_for(:new, Project).each do |key, value|
  @project.send("#{key}=", value)
@project.attributes = params[:project]
authorize! :new, @project

I want to implement role based mass-assingment and then referred screenshot … asciicast.
as per tutorial, I got the following points,

In the controller we also need to apply the accessible option to the create action.
if we just apply it like this then it will not work.

@article =[:article])
@article.accessible = :all if admin?

The reason that this doesn’t work is that the mass assignment happens in the new call so by the time we’ve set accessible it’s too late. We need to separate creating a new Article from assigning its attributes and slip the call to accessible in between the two.

@article =
@article.accessible = :all if admin?
@article.attributes = params[:article]

How can I include the following code after initialize object using load_and_authorize_resource

object.accessible = :all or 
object.accessible = :important