Rails already provides methods for creating class level and module level variables in the form of cattr** and mattr** suite of methods. In Rails 5, we can go a step further and create thread specific class or module level variables. Here is an example which demonstrates an example on how to use it. 1 2module CurrentScope 3 thread_mattr_accessor :user_permissions 4end 5 6class ApplicationController
![Rails 5 Create module and class level variables](https://cdn-ak-scissors.b.st-hatena.com/image/square/df7dcf3e382d2d4b018ba79fc6642260e3fa7070/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fdpc4i4bdx%2Fimage%2Fupload%2Fbigbinary_blogs%2Fdefault_blog_image.png)