@AhmedOsam script should be placed inside app/assets/javascripts not in the view file