Guest User

Untitled

a guest
Aug 14th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. Is it possible to render a js file with Rails and minify the output?
  2. def action_name
  3. js_code = render_to_string 'your_js_code_view'
  4. js_code.gsub!(/rn|r|n/, '') #and/or any other minimization you like
  5. render 'the_view_wich_will_show_the_minimized_js_code'
  6. end
  7.  
  8. respond_to do |format|
  9. format.js { self.response_body = minify(render_to_string) }
  10. end
Add Comment
Please, Sign In to add comment