Although you can use .js.erb extension for any .js file you have to understand WHEN that erb gets executed to understand what you can do with it.
Assets with .erb extension are compiled to JS code during the assets precompilation process, you can't put request dependant code (current_user, instance variables, request controller/action, etc) inside an .js.erb asset file because it's an isolated process (assets are compiled into one final static .js bundle).
You can put request dependant code on .js.erb VIEWS because views are executed when they are needed for each request.
Not all js files are used the same way, you can use .erb extension to have ruby code but have to take into account the context to understand what variables you have access to.