I sleep better with it in place in production mode and I only get one error notice - every once in a while for a problem that I have fixed in development branch that I am not ready to merge in the main trunk yet. I want to keep the error mailer code in place in development code for obvious reasons and even though I can set up filters for my mail system, how can I simply shut it off for development mode? Craig
I''ve been getting errors when I Marshal ActiveRecord objects in my app. The following will throw a TypeError every time: session[:user] = Person.create(hash) However, the following will not throw a TypeError: person = Person.find(1) session[:user] = person This will not throw a TypeError either: person = Person.create(hash) person.reload session[:user] = person If I had to guess, I would guess that Person.create() returns an ActiveRecord object that possibly references a database connection, or some other attribute that can''t be Marshalled. Person.find() returns an ActiveRecord object where all attributes can be Marshalled. Does anyone have more in depth information on why one can be Marshaled and not the other? Anyway, the rails docs make no reference regarding a possible difference with the state of the object returned by create() vs find(). Regards, Steven
On Mon, 2006-07-03 at 16:32 -0600, Steven Hansen wrote:> I''ve been getting errors when I Marshal ActiveRecord objects in my app. > > The following will throw a TypeError every time: > > session[:user] = Person.create(hash) > > > However, the following will not throw a TypeError: > > person = Person.find(1) > session[:user] = person > > This will not throw a TypeError either: > > person = Person.create(hash) > person.reload > session[:user] = person > > > If I had to guess, I would guess that Person.create() returns an > ActiveRecord object that possibly references a database connection, or > some other attribute that can''t be Marshalled. Person.find() returns an > ActiveRecord object where all attributes can be Marshalled. Does anyone > have more in depth information on why one can be Marshaled and not the > other? Anyway, the rails docs make no reference regarding a possible > difference with the state of the object returned by create() vs find().---- my first thought is that rather than creating a new email to the rubyonrails.org mail list, you clicked reply to my message which just intruded onto my thread. my second thought is that the reason session[:user] Person.create(hash) throws an error is that Person.create is a method, not an object. If you assign a variable (hash or otherwise) then you can possibly set a session[:hash_key] => variable (not session[:has_key] => method Craig
Hi Craig, My apologies. I didn''t mean to interrupt your thread. I thought threads were managed by the Subject and that if I simply altered the subject then your thread would not be touched. BTW, Person.create() returns a reference to an object. -Steven Craig White wrote:> On Mon, 2006-07-03 at 16:32 -0600, Steven Hansen wrote: > >> I''ve been getting errors when I Marshal ActiveRecord objects in my app. >> >> The following will throw a TypeError every time: >> >> session[:user] = Person.create(hash) >> >> >> However, the following will not throw a TypeError: >> >> person = Person.find(1) >> session[:user] = person >> >> This will not throw a TypeError either: >> >> person = Person.create(hash) >> person.reload >> session[:user] = person >> >> >> If I had to guess, I would guess that Person.create() returns an >> ActiveRecord object that possibly references a database connection, or >> some other attribute that can''t be Marshalled. Person.find() returns an >> ActiveRecord object where all attributes can be Marshalled. Does anyone >> have more in depth information on why one can be Marshaled and not the >> other? Anyway, the rails docs make no reference regarding a possible >> difference with the state of the object returned by create() vs find(). >> > ---- > my first thought is that rather than creating a new email to the > rubyonrails.org mail list, you clicked reply to my message which just > intruded onto my thread. > > my second thought is that the reason session[:user] > Person.create(hash) throws an error is that Person.create is a method, > not an object. If you assign a variable (hash or otherwise) then you can > possibly set a session[:hash_key] => variable (not session[:has_key] => > method > > Craig > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Mon, 2006-07-03 at 16:59 -0600, Steven Hansen wrote:> Hi Craig, > > My apologies. I didn''t mean to interrupt your thread. I thought > threads were managed by the Subject and that if I simply altered the > subject then your thread would not be touched.---- threads are maintained by an id # in the header ----> > BTW, Person.create() returns a reference to an object.---- that is why you can set person = Person.create() but Person.create() is a method that returns an object Craig> > -Steven > > Craig White wrote: > > On Mon, 2006-07-03 at 16:32 -0600, Steven Hansen wrote: > > > >> I''ve been getting errors when I Marshal ActiveRecord objects in my app. > >> > >> The following will throw a TypeError every time: > >> > >> session[:user] = Person.create(hash) > >> > >> > >> However, the following will not throw a TypeError: > >> > >> person = Person.find(1) > >> session[:user] = person > >> > >> This will not throw a TypeError either: > >> > >> person = Person.create(hash) > >> person.reload > >> session[:user] = person > >> > >> > >> If I had to guess, I would guess that Person.create() returns an > >> ActiveRecord object that possibly references a database connection, or > >> some other attribute that can''t be Marshalled. Person.find() returns an > >> ActiveRecord object where all attributes can be Marshalled. Does anyone > >> have more in depth information on why one can be Marshaled and not the > >> other? Anyway, the rails docs make no reference regarding a possible > >> difference with the state of the object returned by create() vs find(). > >> > > ---- > > my first thought is that rather than creating a new email to the > > rubyonrails.org mail list, you clicked reply to my message which just > > intruded onto my thread. > > > > my second thought is that the reason session[:user] > > Person.create(hash) throws an error is that Person.create is a method, > > not an object. If you assign a variable (hash or otherwise) then you can > > possibly set a session[:hash_key] => variable (not session[:has_key] => > > method > > > > Craig > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On Mon, 2006-07-03 at 15:49 -0700, Craig White wrote:> I sleep better with it in place in production mode and I only get one > error notice - every once in a while for a problem that I have fixed in > development branch that I am not ready to merge in the main trunk yet. I > want to keep the error mailer code in place in development code for > obvious reasons and even though I can set up filters for my mail system, > how can I simply shut it off for development mode?---- is there something I can put at the top of error_mailer.rb model file that would have this only work in RAILS_ENV=production ? Craig