Tag: ruby on rails
-
JQuery AJAX with Rails’ authenticity token
In Ruby on Rails, authenticity tokens are generated to prevent CSRF (Cross Site Request Forgery) attacks. These tokens generate a unique “identifier” to prevent other website from making requests on your behalf, or so-called “session riding”. In Ruby on Rails, to have this identifier available for you, you need to put in your view, usually…
-
Spaces, or parentheses are important
In Rails, j = points.size -1 is not equal to j = points.size – 1 Wouldn’t it be easier if Parentheses were mandatory, so that we could see the difference between: j = points.size -1 and j = points.size(-1)
-
Find “similar things” in Ruby
For several Ruby on Rails projects I had to come up with “similar” results. These are often results (video’s, products,places, hobbies, etc) with the greatest number of tags. Say, you are tagging car pictures on a website, and have the following: image1.jpg -> [“honda”,”s2000″,”convertible”,”black”] image2.jpg -> [“honda”,”civic”,”blue”] image3.jpg -> [“lexus”,”is300″,”blue”] image4.jpg -> [“s2000″,”honda”,”convertible”,”silver”] image5.jpg ->…