Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Looks like there are a couple of potential issues here.</p> <p>For one, is your <code>if</code> statement actually on a separate line than your <code>errors.add_to_base...</code> statement? If so, your syntax is wrong; the <code>if</code> statement needs to be in the same line as the statement it's modifying. Even if it is actually on the correct line, I would recommend against using a trailing <code>if</code> statement on such a long line; it will make it hard to find the conditional.</p> <pre><code>if m.match(post.responses.last.to_s.strip) != 1.0 errors.add_to_base("Sorry, you must change the last submitted word by one letter") end </code></pre> <p>Second, doing exact equality comparison on floating point numbers is almost never a good idea. Because floating point numbers involve approximations, you will sometimes get results that are very close, but not quite exactly equal, to a given number that you are comparing against. It looks like the Amatch library has several different classes for comparing strings; the Sellers class allows you to set different weights for different kinds of edits, but given your problem description, I don't think you need that. I would try using the <a href="http://flori.github.com/amatch/doc/Amatch/Levenshtein.html" rel="nofollow noreferrer">Levenshtein</a> or <a href="http://flori.github.com/amatch/doc/Amatch/Hamming.html" rel="nofollow noreferrer">Hamming</a> distance instead, depending on your exact needs.</p> <p>Finally, if neither of those suggestions work, try writing out to a log or in the response the exact values of <code>title.strip</code> and <code>post.responses.last.to_s.strip</code>, to make sure you are actually comparing the values that you think you're comparing. I don't know the rest of your code, so I can't tell you whether those are correct or not, but if you print them out somewhere, you should be easily able to check them yourself.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload