This issue is really losing me.
I have a model for authentication : user. I have a model for comments : comment. I have a model that is commentable : weburl.
Weburl 1..* Comment Weburl *..1 User Comment *..1 User
The issue I have is not testable (my tests are all passing), and does not happen all the time. Usually it happens the second time I generate the same controller action.
Issue is my user associated to my comment, and retrieve through comment.user become NOT EQUAL to current_user, even if the attributes are the same. For example :
(comment.user.login == current_user.login == User.find(1).login)
==> True
(comment.user.id)
==> Unknown in the current context
(comment.user.class == User == current_user.class)
==> True
I doubled check the relationships belongs_to
and has_one has_many
in my models
My guess is that is something to do with caching, I'm experiencing this on my development environment, but not in my automated tests nor in production.
I'd like to understand what is the issue.
Thanks
EDIT Adding my development.rb init file
config.cache_classes = false #Set to true for prod
config.whiny_nils = true
config.action_controller.consider_all_requests_local = true #Set to false for prod
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false #Set to true for prod
EDIT #2 If config.cache_classes is true, the error is not happenning
Doc says : # In the development environment your application's code is reloaded on every request. This slows down response time but is perfect for development since you dont have to restart the webserver when you make code changes.
found the following ticket, might be interrelated http://dev.rubyonrails.org/ticket/10722 Also, issue happens with Mongrel and WebRick.