Changes to be compatible with Rails 3.2.12

Use of jquery, some string parsing and use scope instead of
named_scopes