This project is archived and is in readonly mode.
undefined method `money_precision=' for #<Class:0x105d7dda8> in postgresql_adapter.rb
-
Jippi
My local gems:
*** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.0.beta4, 3.0.0.beta3, 2.3.8, 2.3.5, 2.2.2, 1.3.6) actionpack (3.0.0.beta4, 3.0.0.beta3, 2.3.8, 2.3.5, 2.2.2, 1.13.6) actionwebservice (1.2.6) activemodel (3.0.0.beta4, 3.0.0.beta3) activerecord (3.0.0.beta4, 3.0.0.beta3, 2.3.8, 2.3.5, 2.2.2, 1.15.6) activeresource (3.0.0.beta4, 3.0.0.beta3, 2.3.8, 2.3.5, 2.2.2) activesupport (3.0.0.beta4, 3.0.0.beta3, 2.3.8, 2.3.5, 2.2.2, 1.4.4) acts_as_ferret (0.4.7, 0.4.4, 0.4.3) addressable (2.1.2) annotate (2.4.0) arel (0.4.0, 0.3.3) authlogic (2.1.5, 2.1.3) aws (2.3.13, 2.3.9) builder (2.1.2) bullet (1.7.6) bundler (1.0.0.beta.4, 0.9.26, 0.9.25, 0.9.21) calendar_date_select (1.16.1) capistrano (2.5.19, 2.5.18, 2.5.2) carrierwave (0.4.5) cgi_multipart_eof_fix (2.5.0) clearance (0.8.8) columnize (0.3.1) configuration (1.1.0) crack (0.1.8, 0.1.7, 0.1.6) cucumber (0.8.3, 0.8.0, 0.7.2) cucumber-rails (0.3.2, 0.3.1) daemons (1.1.0, 1.0.10) desert (0.5.4, 0.5.3) diff-lcs (1.1.2) dnssd (1.3.1, 0.6.0) erubis (2.6.6, 2.6.5) facebook_oauth (0.2.0) factory_girl (1.3.1, 1.3.0, 1.2.4) faraday (0.4.6, 0.4.5) fastthread (1.0.7, 1.0.1) fcgi (0.8.8, 0.8.7) ferret (0.11.6) formtastic (0.9.10, 0.9.8) gem_plugin (0.2.3) getopt (1.4.0) gherkin (2.0.2, 1.0.30, 1.0.26) haml (3.0.13, 3.0.12, 3.0.10, 3.0.2) has_scope (0.5.0) hashie (0.2.1, 0.2.0) heroku (1.9.11, 1.9.9) highline (1.5.2, 1.5.0) hpricot (0.8.2, 0.6.164) htmlentities (4.2.1) http_connection (1.3.0) httparty (0.6.1, 0.5.2) i18n (0.4.1, 0.3.6) icalendar (1.1.5, 1.1.4) inherited_resources (1.1.2) jeremymcanally-context (0.5.5) jferris-mocha (0.9.8.20100526112143, 0.9.7.20090911190113) jnunemaker-matchy (0.4.0) json (1.4.3, 1.2.4) json_pure (1.4.3) justinfrench-formtastic (0.2.4) launchy (0.3.5) libxml-ruby (1.1.4, 1.1.3, 1.1.2) linecache (0.43) log4r (1.1.8, 1.1.7) mail (2.2.5, 2.2.3, 2.2.1, 2.2.0, 2.1.5.3) memcache-client (1.8.5, 1.8.3, 1.8.2, 1.7.8) mime-types (1.16) modularity (0.6.0) mongrel (1.1.5) multi_json (0.0.4) needle (1.3.0) net-scp (1.0.2, 1.0.1) net-sftp (2.0.4, 2.0.1, 1.1.1) net-ssh (2.0.23, 2.0.21, 2.0.4, 1.1.4) net-ssh-gateway (1.0.1, 1.0.0) newrelic_rpm (2.12.3, 2.12.1, 2.11.1) nokogiri (1.4.2, 1.4.1) oauth (0.4.1, 0.4.0) oauth2 (0.0.10, 0.0.8) paper_trail (1.5.2, 1.5.0) pg (0.9.0) polyglot (0.3.1) rack (1.2.1, 1.1.0, 1.0.1) rack-mount (0.6.6, 0.6.4, 0.6.3, 0.4.7) rack-test (0.5.4, 0.5.3) rails (3.0.0.beta4, 2.3.8, 2.3.5, 2.2.2, 1.2.6) rails3b (3.0.1) railties (3.0.0.beta4, 3.0.0.beta3) rake (0.8.7, 0.8.3) rdoc (2.5.9, 2.5.8, 2.5.3) RedCloth (4.2.3, 4.1.1) responders (0.6.1) rest-client (1.6.0, 1.5.1, 1.4.2) ri_cal (0.8.7) rmagick (2.13.1) rspec (1.3.0) rspec-rails (1.3.2) ruby-debug (0.10.3) ruby-debug-base (0.10.3) ruby-growl (2.0) ruby-openid (2.1.7, 2.1.2) ruby-yadis (0.3.4) rubygems-update (1.3.7, 1.3.6) rubynode (0.1.5) searchlogic (2.4.19) shoulda (2.11.1, 2.11.0, 2.10.3) sqlite3-ruby (1.3.1, 1.3.0, 1.2.5, 1.2.4) term-ansicolor (1.0.5) termios (0.9.4) test-unit (2.0.9, 2.0.7) text-format (1.0.0) text-hyphen (1.0.0) thor (0.13.7, 0.13.6, 0.13.4) treetop (1.4.8, 1.4.5) trollop (1.16.2) twitter (0.9.8, 0.9.7, 0.9.5) tzinfo (0.3.22, 0.3.19) unidecode (1.0.0) uuidtools (2.1.1) webrat (0.7.1) xml-simple (1.0.12) xmpp4r (0.5, 0.4) ya2yaml (0.29.2) yajl-ruby (0.7.6) -
Jippi
- Title changed from undefined method `money_precision=' for #<Class:0x105d7dda8> to undefined method `money_precision=' for #<Class:0x105d7dda8> in postgresql_adapter.rb
-
Miles Egan
It's hard to debug this without a little more information. What command are you running to generate this error? Can you share the portion of the schema that this affects?
-
Jippi
Hi Miles,
Thanks for your quick reply.
I'm not sure what to give you - I'm just starting up my application (any postgresql) application on rails3 b4 and the error happens... I tried wipeing all my gems from my system and install the newest, but it didn't have much of an effect.. So I ended up just outcommenting the line causing the error, and everything was great again.
Reading postgresql_adapter.rb line ~907 what the money_precision is invoked, it seems like the object doesn't implement that specific property / method at all..
Can it be related to OSX / gem differences with postgresql? Afaik there is quite a few different postgresql drivers around for ruby.Thanks!
-
Miles Egan
I just tried loading a new Rails 3 app with your gemfile and creating a test class with this definition:
class CreateTestObjects < ActiveRecord::Migration
def self.upcreate_table :test_objects do |t| t.column :value, :money t.timestamps endend
def self.down
drop_table :test_objectsend end
I'm able to start the app, and create and save objects of this type from the console. I'm not sure where to go next.
-
Miles Egan
Sorry about the bad formatting there. Still getting used to this forum. I should add that I'm testing on a Ubuntu machine, so that might account for the difference. Here's the object migration again:
class CreateTestObjects < ActiveRecord::Migration def self.up create_table :test_objects do |t| t.column :value, :money t.timestamps end end def self.down drop_table :test_objects end end -
Simen Svale Skogsrud
I have the same problem and got past it by monkeypatching the connection-adapter like this:
puts "Warning: money_precision_monkeypatch.rb contains a terrible patch for Rail ticket #5081" puts " -- https://rails.lighthouseapp.com/projects/8994/tickets/5081-undefined-method-money_precision-for-class0x105d7dda8" puts module ActiveRecord module ConnectionAdapters class PostgreSQLAdapter private def connect @connection = PGconn.connect(*@connection_parameters) PGconn.translate_results = false if PGconn.respond_to?(:translate_results=) # Ignore async_exec and async_query when using postgres-pr. @async = @config[:allow_concurrency] && @connection.respond_to?(:async_exec) # Money type has a fixed precision of 10 in PostgreSQL 8.2 and below, and as of # PostgreSQL 8.3 it has a fixed precision of 19. PostgreSQLColumn.extract_precision # should know about this but can't detect it there, so deal with it here. ActiveRecord::ConnectionAdapters::PostgreSQLColumn.money_precision = (postgresql_version >= 80300) ? 19 : 10 configure_connection end end end end -
Aditya Sanghi
I confirm that this problem could not be reproduced on OSX with Rails 3.0.0 with ree-1.8.7 and ruby-1.9.2-p0 and using pg gem version 0.9.0
-
David Trasbo
- State changed from new to incomplete
- Importance changed from to Low
Please provide a patch (https://rails.lighthouseapp.com/projects/8994/sending-patches) with a failing test and/or a fix.
-
Aaron Patterson
- State changed from incomplete to invalid
I'm closing this since it hasn't been updated. Please open a new ticket with a failing test and / or a fix if this is still an issue. Thanks.
-
Alex B.
Hi,
I'm actually getting this error too. Trying to migrate a Rails 2.3.x app to 3.x. Believe this is somehow tied to Postgres and the 'pg' gem because if I switch to MySQL it goes away. -
Gavin Brock
Same issue here - I opened #6383 NoMethodError: undefined method `money_precision=' for #<Class:0x0000010321f788> with a fix that worked for me.