How to get Rails to serve my dynamic Greasemonkey script with the proper MIME type? -
this question has answer here:
- rendering file mime type in rails 4 answers
i have static greasemonkey script , works fine. have rails 4 application, , want customize script current user. problem can render script named script.user.js
, content type text/html , greasemonkey can't detect install.
here few lines of code :
routes.rb
resources :users '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 app serve file right type?
try (untested):
def script render file: 'users/script.user.js', content_type: mime::js end
similar problem , answers: "rendering file mime type in rails".
also, op comment (i should have remembered this): clear browser cache let new association take effect.
Comments
Post a Comment