Hi, I''m having trouble with my card not working correctly (not adding to quantity instead of adding full new line item) so I figured I would output some messages to the console to see what clause I am in, so I tried this: def add_product(product) item = @items.find {|i| i.product_id == product.id} if item puts "if clause" item.quantity += 1 else puts "else clause" item = LineItem.for_product(product) @items << item end @total_price += product.price puts "end" end but the puts messages are not showing up...is this not a technique that will work? Is there some other way I can write to the console? Hopefully this is my last dumb question of the evening. Tom http://www.pixelmech.com/
Tom Dell''Aringa wrote:> but the puts messages are not showing up...is this not a technique > that will work? Is there some other way I can write to the console?When runnign Webrick it should "work", ie display the output in the Webrick console window. When running FastCGI I hear rumours it''ll crash the FastCGI handler. Undefined results outside of those two scenarios, I guess. A better way to go about it would probably be to add to your logfile: logger.info("if clause") -- Jakob Skjerning - http://mentalized.net
--- Jakob Skjerning <jakob-pixy5vpirPnEueBKFXcDjA@public.gmane.org> wrote:> Tom Dell''Aringa wrote: > > but the puts messages are not showing up...is this not a technique > > that will work? Is there some other way I can write to the console? > > When runnign Webrick it should "work", ie display the output in the > Webrick console window. When running FastCGI I hear rumours it''ll crash > the FastCGI handler. Undefined results outside of those two scenarios, I > guess.I''m not using FastCGI and am using Webrick.> A better way to go about it would probably be to add to your logfile: > > logger.info("if clause")Makes sense, but I got this error when trying it: undefined local variable or method `logger'' for #<Cart:0x385cd88 @total_price=0.0, @items=[]> Do I have to declare logger somehow? Tom http://www.pixelmech.com/
If you are in a model or controller you access the logger via the logger variable. If you are in a view you access the logger via the @logger variable. http://wiki.rubyonrails.com/rails/pages/HowtoAccessTheLogFile On 11/8/05, Tom Dell''Aringa <pixelmech-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> --- Jakob Skjerning <jakob-pixy5vpirPnEueBKFXcDjA@public.gmane.org> wrote: > > > Tom Dell''Aringa wrote: > > > but the puts messages are not showing up...is this not a technique > > > that will work? Is there some other way I can write to the console? > > > > When runnign Webrick it should "work", ie display the output in the > > Webrick console window. When running FastCGI I hear rumours it''ll crash > > the FastCGI handler. Undefined results outside of those two scenarios, I > > guess. > > I''m not using FastCGI and am using Webrick. > > > A better way to go about it would probably be to add to your logfile: > > > > logger.info("if clause") > > Makes sense, but I got this error when trying it: > > undefined local variable or method `logger'' for #<Cart:0x385cd88 @total_price=0.0, @items=[]> > > Do I have to declare logger somehow? > > Tom > > > http://www.pixelmech.com/ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Frank Kim http://meetingkoreans.com http://betweengo.com
puts never worked for me with webrick. Try: warn ''blah blah'' .... On 11/8/05, Frank Kim <mtmusko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If you are in a model or controller you access the logger via the > logger variable. > If you are in a view you access the logger via the @logger variable. > > http://wiki.rubyonrails.com/rails/pages/HowtoAccessTheLogFile > > On 11/8/05, Tom Dell''Aringa <pixelmech-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > --- Jakob Skjerning <jakob-pixy5vpirPnEueBKFXcDjA@public.gmane.org> wrote: > > > > > Tom Dell''Aringa wrote: > > > > but the puts messages are not showing up...is this not a technique > > > > that will work? Is there some other way I can write to the console? > > > > > > When runnign Webrick it should "work", ie display the output in the > > > Webrick console window. When running FastCGI I hear rumours it''ll crash > > > the FastCGI handler. Undefined results outside of those two scenarios, I > > > guess. > > > > I''m not using FastCGI and am using Webrick. > > > > > A better way to go about it would probably be to add to your logfile: > > > > > > logger.info("if clause") > > > > Makes sense, but I got this error when trying it: > > > > undefined local variable or method `logger'' for #<Cart:0x385cd88 @total_price=0.0, @items=[]> > > > > Do I have to declare logger somehow? > > > > Tom > > > > > > http://www.pixelmech.com/ > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Frank Kim > http://meetingkoreans.com > http://betweengo.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >