I’m having a hard time with a scope within an ActiveRecord model.
Here’s my class: https://gist.github.com/1622314
The scope is named “current” and should select records between two
dates and here is what happens:
This is the output for a rails console session, it contains logging to
the STDOUT so you’ll see the executed SQL commands there.
Here’s a quick explanation for that console output:
Line 1 shows there’s no Message record.
Line 4 creates a Message
Line 14 calls the “current” named scope that should fetch the recently
created message and shows how this message is not retrieved.
However, if I exit the console and then re-enter the console,
Message.current does retrieve the recently created record.
I’m using Rails 3.1.3 and Ruby 1.9.3-p0.
It wasn’t happening on Rails 3.0 and Ruby 1.9.2-p290
Thanks a lot in advance.
There’s no place like ~