I''m using rails 2.0.5 and mongrel.
I have a Page and a Source models.
class Source < ActiveRecord::Base
has_many :pages
end
class Page < ActiveRecord::Base
belongs_to :source
end
Basically I''m listing pages with their sources; In production and
development ( I use mongrel_cluster in the first and a single mongrel
on the second) I got this error:
ActiveRecord::AssociationTypeMismatch (Source expected, got Fixnum):
/vendor/rails/activerecord/lib/active_record/associations/
association_proxy.rb:150:in `raise_on_type_mismatch''
/vendor/rails/activerecord/lib/active_record/associations/
belongs_to_association.rb:22:in `replace''
[...]
The fact that scares me *a lot* is that I get it on random basis and
reloading the page solves it.
It looks like that sometimes the record isn''t retrieved correctly from
the db but instead it got a fixnum.
The fact that is a random behaviour doesn''t give me any clue on how to
solve it.
Any idea?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
what exaclty means randomly? does it happen in different places? is your own code mentioned in the trace? wich call would fail? it seems your code is expection an instance of Source but is getting a number (maybe the id) instead. in order to find the piece of code that is causing the error, you gotta try reproducing it. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Randomly means that usually the page load without errors, but somethimes the same page throws the error above. Refreshing the page fixes the problem. On 2 Feb, 12:11, MaD <mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> what exaclty means randomly? does it happen in different places? is > your own code mentioned in the trace? wich call would fail? > > it seems your code is expection an instance of Source but is getting a > number (maybe the id) instead. > > in order to find the piece of code that is causing the error, you > gotta try reproducing it.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2 Feb 2009, at 10:49, An wrote:> > The fact that scares me *a lot* is that I get it on random basis and > reloading the page solves it. > It looks like that sometimes the record isn''t retrieved correctly from > the db but instead it got a fixnum. > > > The fact that is a random behaviour doesn''t give me any clue on how to > solve it. > Any idea? >I would at least start by following that stack trace a little further. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
MaD wrote in post #776440:> what exaclty means randomly? does it happen in different places? is > your own code mentioned in the trace? wich call would fail? > > it seems your code is expection an instance of Source but is getting a > number (maybe the id) instead. > > in order to find the piece of code that is causing the error, you > gotta try reproducing it.>>>>>>>>>>>>>ansif you will remove (belongs_to :model name) then it will work -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Possibly Parallel Threads
- Forms: handle foreign keys (AssociationTypeMismatch)
- expected, got Fixnum problem.
- Paperclip attachment to AWS - ActiveRecord::AssociationTypeMismatch Going Nuts!
- Paperclip attachment to AWS - ActiveRecord::AssociationTypeMismatch
- Problem with ActiveRecord::AssociationTypeMismatch