From: Ferhat A. <fer...@ya...> - 2008-01-20 12:05:01
|
Hi Eloy, I'm using NSDecimalNumber to avoid rounding problem. I'm not sure whether it's soo important in that case. But imho keypaths like @sum.retail_price can produce side effects. Thanks! Ferhat ----- Original Message ---- From: Eloy Duran <e....@su...> To: rub...@li... Sent: Sunday, January 20, 2008 12:45:11 PM Subject: Re: [Rubycocoa-talk] NSProxy doesNotRecognizeSelector:copyWithZone: [SOLVED] Normally I would say try: OSX::NSDecimalNumber.decimalWithDecimal(content), but for some reason it expects 6 arguments instead of 1. Ok scrap that. It's because it expects a NSDecimal structure. How to create one I haven't found yet though.... Eloy On 20 jan 2008, at 09:13, Ferhat Ayaz wrote: ah! ok. Thank you very much. This does the trick. BTW, has somebody a more elegant solution to make a decimal number? class ProductProxy < OSX::ActiveRecordProxy on_get :retail_price do |content| OSX::NSDecimalNumber.alloc.initWithString(content.to_s) end end Thanks, Ferhat ----- Original Message ---- From: Eloy Duran <e....@su...> To: rub...@li... Sent: Sunday, January 20, 2008 2:19:46 AM Subject: Re: [Rubycocoa-talk] NSProxy doesNotRecognizeSelector:copyWithZone: Hi, Have you tried using a on_get filter to change the value that is returned ActiveRecord into something the table column wants? For an example of this see: http://www.superalloy.nl/blog/2007/06/09/added-on_get-filter-class-method-to-activerecordproxy/ Eloy On 20 jan 2008, at 01:55, Ferhat Ayaz wrote: Hi, I think I have an idea whats going wrong. I'm binding the arrangedObjects of ActiveRecordSetController to NSTableView column (usual stuff). But this is interesting: the decimal column (in my case the price of product) is the problem. I used an NSNumberFormatter in the table column cell to confirm this. And, indeed, I got this error: OSX::OCException: NSInternalInconsistencyException - Cannot create number from object <RBObject: 0x228b3b0> of class RBObject I think RBObject is in this case not the right type, is it? If I do not bind the price column, everything work fine. Is this a bug or am I just poor of knowledge? Thanks, Ferhat ----- Original Message ---- From: Ferhat Ayaz <fer...@ya...> To: rub...@li... Sent: Saturday, January 19, 2008 7:35:50 PM Subject: Re: [Rubycocoa-talk] NSProxy doesNotRecognizeSelector:copyWithZone: Hi Eloy, thank you for your reply. I'm trying to access an already existing database created by a rails application. The migration for the products table looks like this create_table :products do |t| t.column :title, :string t.column :description, :text t.column :image, :string t.column :price, :decimal, :null => false, :precision => 8, :scale => 2 t.column :asset, :decimal, :null => false, :precision => 8, :scale => 2 t.column :accepts_contract, :boolean, :default => true t.column :rank, :integer t.column :manufacturer_id, :integer t.column :created_at, :datetime t.column :updated_at, :datetime end (There are also other tables which I don't care for my rubycocoa application) Although there is a manufacturer_id, I didn't generate Manufacturer.rb using the generate.rb script (hint). This is really everything I've done. The following line causes the exception @products = Product.find(:all).to_activerecord_proxies If I try to use the first version without active_record, say: @products = [] everything is ok. The kvc_accessor :products is bind to the contentArray of an ActiveRecordSetController. RubyCocoa Version: 0.12.0 Thanks. Ferhat ----- Original Message ---- From: Eloy Duran <elo...@gm...> To: rub...@li...urceforge..net Sent: Saturday, January 19, 2008 7:02:44 PM Subject: Re: [Rubycocoa-talk] NSProxy doesNotRecognizeSelector:copyWithZone: Hi Ferhat, Unfortunately that error is too much of a general problem to be able to diagnose for me. Could you try to get some more detailed info on which code is causing the problem? Cheers, Eloy On 18-jan-2008, at 22:59, Ferhat Ayaz <fer...@ya...> wrote: Hi, I'm trying to run an activerecordsupport application. I have added an ActiveRecordSetController ArrayController in IB and set the class name properly (in my case ProductProxy). here my simple controller code (inspired by the blog article by Eloy Duran) require 'osx/cocoa' class CNController < OSX::NSWindowController kvc_accessor :products def init if super_init ActiveRecord::Base.establish_connection({ :adapter => 'mysql', :host => 'localhost', :username => 'root', :password => '', :database => 'xyz_development' }) @products = Product.find(:all).to_activerecord_proxies return self end end end I have generated product.rb and product_proxy..rb using the handy generate.rb script. So, the error message I get is the following [Session started at 2008-01-18 22:51:02 +0100.] /Users/ayaz/Projects/CNClient/build/Debug/CNClient.app/Contents/Resources/rb_main.rb:24:in `NSApplicationMain': NSInvalidArgumentException - *** -[NSProxy doesNotRecognizeSelector:copyWithZone:] called! (OSX::OCException) from /Users/ayaz/Projects/CNClient/build/Debug/CNClient.app/Contents/Resources/rb_main.rb:24 The Debugger has exited with status 1.The Debugger has exited with status 1. Any idea? Thanks! Ferhat Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Rubycocoa-talk mailing list Rub...@li... https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk Never miss a thing. Make Yahoo your homepage. Never miss a thing. Make Yahoo your homepage. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ Rubycocoa-talk mailing list Rub...@li... https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk Looking for last minute shopping deals? Find them fast with Yahoo! Search.------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ Rubycocoa-talk mailing list Rub...@li... https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |