The Bull Og

Onine since 1994. Offline since 1976.

See also the archive

An individual post follows.

I had my first experiences with Webrat last Thursday and I came across this error: NoMethodError: You have a nil object when you didn't expect it! The error occurred while evaluating nil.fields (eval):2:in `choose' Not being able to decipher that, I turned to the web and found this helpful link which didn't completely solve my problem but did point me in the right direction: check the markup. Looking at what I had:
<tr>
<td>
  <input type="radio" value="1" name="my_radio_btn" id="my_radio_btn">
</td>
<td id="l">
  <label for="my_radio_btn">My Radio Button</label>
</td>
</tr>
...there wasn't a <form> anywhere in sight. Once I fixed the markup to be:
<tr>
<td>
  <form id="better_markup">
      <input type="radio" value="1" name="my_radio_btn" id="my_radio_btn">
  </form>
</td>
<td id="l">
  <label for="my_radio_btn">My Radio Button</label>
</td>
</tr>
... Webrat worked like a charm.