How to get Rails to serve my dynamic Greasemonkey script with the proper MIME type? -


this question has answer here:

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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -