This project is archived and is in readonly mode.
undefined method `money_precision=' for #<Class:0x105d7dda8> in postgresql_adapter.rb
Reported by Jippi | July 10th, 2010 @ 04:42 PM
I get the following error when trying to work with rails 3.0.0.beta4 and postgresql
My Gemfile
source 'http://rubygems.org'
# gem 'rails', '3.0.0.beta4'
# Bundle edge Rails instead:
gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
gem 'ruby-debug'
gem 'rmagick'
gem 'unidecode'
gem 'formtastic'
gem 'clearance'
gem 'paper_trail'
gem 'RedCloth'
gem 'oauth'
gem 'facebook_oauth'
gem 'twitter'
gem 'ya2yaml'
gem 'inherited_resources', '1.1.2'
and my stack trace
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/postgresql_adapter.rb:907:in `connect'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/postgresql_adapter.rb:219:in `initialize'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `new'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/postgresql_adapter.rb:25:in `postgresql_connection'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_pool.rb:226:in `send'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_pool.rb:226:in `new_connection'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_pool.rb:248:in `checkout_new_connection'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `checkout'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `loop'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_pool.rb:186:in `checkout'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_pool.rb:185:in `checkout'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_pool.rb:99:in `connection'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_pool.rb:330:in `retrieve_connection'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_specification.rb:103:in `retrieve_connection'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_specification.rb:95:in `connection'
activerecord (3.0.0.beta4) lib/active_record/query_cache.rb:11:in `cache'
activerecord (3.0.0.beta4) lib/active_record/query_cache.rb:30:in `call'
activerecord (3.0.0.beta4) lib/active_record/connection_adapters/abstract/connection_pool.rb:365:in `call'
actionpack (3.0.0.beta4) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
activesupport (3.0.0.beta4) lib/active_support/callbacks.rb:414:in `_run_call_callbacks'
activesupport (3.0.0.beta4) lib/active_support/callbacks.rb:88:in `send'
activesupport (3.0.0.beta4) lib/active_support/callbacks.rb:88:in `run_callbacks'
actionpack (3.0.0.beta4) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
/Users/jippignu/.bundle/ruby/1.8/bundler/gems/rack-7f693f2e7da5dbeb0403886fdee49dbe39a6beda-master/lib/rack/sendfile.rb:105:in `call'
actionpack (3.0.0.beta4) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.0.beta4) lib/action_dispatch/middleware/show_exceptions.rb:48:in `call'
railties (3.0.0.beta4) lib/rails/rack/logger.rb:14:in `call'
/Users/jippignu/.bundle/ruby/1.8/bundler/gems/rack-7f693f2e7da5dbeb0403886fdee49dbe39a6beda-master/lib/rack/runtime.rb:17:in `call'
activesupport (3.0.0.beta4) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/Users/jippignu/.bundle/ruby/1.8/bundler/gems/rack-7f693f2e7da5dbeb0403886fdee49dbe39a6beda-master/lib/rack/lock.rb:11:in `call'
/Users/jippignu/.bundle/ruby/1.8/bundler/gems/rack-7f693f2e7da5dbeb0403886fdee49dbe39a6beda-master/lib/rack/lock.rb:11:in `synchronize'
/Users/jippignu/.bundle/ruby/1.8/bundler/gems/rack-7f693f2e7da5dbeb0403886fdee49dbe39a6beda-master/lib/rack/lock.rb:11:in `call'
actionpack (3.0.0.beta4) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.0.beta4) lib/rails/application.rb:145:in `call'
railties (3.0.0.beta4) lib/rails/application.rb:81:in `send'
railties (3.0.0.beta4) lib/rails/application.rb:81:in `method_missing'
railties (3.0.0.beta4) lib/rails/rack/log_tailer.rb:15:in `call'
/Users/jippignu/.bundle/ruby/1.8/bundler/gems/rack-7f693f2e7da5dbeb0403886fdee49dbe39a6beda-master/lib/rack/content_length.rb:13:in `call'
/Users/jippignu/.bundle/ruby/1.8/bundler/gems/rack-7f693f2e7da5dbeb0403886fdee49dbe39a6beda-master/lib/rack/handler/webrick.rb:48:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/Users/jippignu/.bundle/ruby/1.8/bundler/gems/rack-7f693f2e7da5dbeb0403886fdee49dbe39a6beda-master/lib/rack/handler/webrick.rb:14:in `run'
/Users/jippignu/.bundle/ruby/1.8/bundler/gems/rack-7f693f2e7da5dbeb0403886fdee49dbe39a6beda-master/lib/rack/server.rb:155:in `start'
railties (3.0.0.beta4) lib/rails/commands/server.rb:62:in `start'
railties (3.0.0.beta4) lib/rails/commands.rb:30
railties (3.0.0.beta4) lib/rails/commands.rb:27:in `tap'
railties (3.0.0.beta4) lib/rails/commands.rb:27
script/rails:6:in `require'
script/rails:6
Edited by Rohit Arondekar for formating.
Comments and changes to this ticket
-
Jippi July 10th, 2010 @ 05:08 PM
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 July 10th, 2010 @ 05:09 PM
- Title changed from undefined method `money_precision=' for #<Class:0x105d7dda8> to undefined method `money_precision=' for #<Class:0x105d7dda8> in postgresql_adapter.rb
-
Miles Egan July 11th, 2010 @ 06:53 PM
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 July 11th, 2010 @ 06:57 PM
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 July 11th, 2010 @ 08:28 PM
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 end
end
def self.down
drop_table :test_objects
end 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 July 11th, 2010 @ 08:29 PM
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 October 4th, 2010 @ 11:21 AM
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
-
gnufied October 7th, 2010 @ 11:53 AM
- Assigned user set to Aaron Patterson
@Simen, Can you turn this into a patch?
-
Aditya Sanghi October 7th, 2010 @ 06:44 PM
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 October 9th, 2010 @ 03:38 PM
- 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 December 11th, 2010 @ 12:05 AM
- 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. December 22nd, 2010 @ 04:01 AM
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 February 7th, 2011 @ 01:07 AM
Same issue here - I opened #6383 with a fix that worked for me.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Referenced by
- 6383 NoMethodError: undefined method `money_precision=' for #<Class:0x0000010321f788> This is a fix for the invalid ticket: #5081