Activerecord query updated
pg gem added for heroku
Jquery added to avoid duplicate ajax call