I have a static Greasemonkey script and it works fine.
I have a rails 4 application, and I just want to customize my script for current user.
My problem is I can render the script named script.user.js
, but the content type is always text/html and Greasemonkey can't detect it for install.
Here few lines of code :
routes.rb
resources :users do
get 'script.user.js', :action => 'script', :on => :collection
end
users_controller.rb
def script
render file: 'users/script.user.js', content_type: "application/x-javascript"
end
How do I get my app to serve this file with the right type?