Activerecord not working

Hi all, I have a table like the one below called key_value_pairs

id spec val 1 size small 2 size medium 3 size small

In my controller i have

  def edit     @pair = KeyValuePair.find(params[:id])   end

and in my view i have such code as <%= @pair.val %>.

This code was all working as expected before (before what i'm not sure, but now it no longer works) as far as im aware i have made no changes to the edit method in the controller or any changes to the view and all the data is still in the database table but now when i try and view the page i get nil object error message

You have a nil object when you didn't expect it! The error occurred while evaluating nil.val

Does any one have any suggestions or ideas? has this happened to anyone else?

I am not sure how to proceed as all my code (which is rather simple) looks like it should work.

There's not enough information to know what the problem is. The find() should raise an exception if the record isn't found, so I suspect that for some reason, the find() isn't being performed, and thus @pair isn't being set.

One quick thing you can do is to temporarily add this to your controller right after the find:

   raise @pair.inspect

Then call your action from the browser. If you still get the view error, then the find didn't happen.