Problems with money 1.7.1 gem and rails 2.1.0 as part of AM requirements.

49 views
Skip to first unread message

stjohn goldfinger

unread,
Jun 11, 2008, 10:01:33 AM6/11/08
to activemerchant digest subscribers
Hi,
has anyone used the money 1.7.1 rails gem with vendor rails 2.1.0? I am having
some problems getting it to work. It should be quite straight forward but
when I require it in via my environment.rb and test it out with say
script/server I get this:

*****************myservrer..........
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails 2.1.0 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
Exiting
/usr/local/lib/ruby/gems/1.8/gems/money-1.7.1/lib/support/cattr_accessor.rb:7:in
`cattr_reader': undefined method `id2name' for {:instance_writer=>false}:Hash
(NoMethodError)

from /usr/local/lib/ruby/gems/1.8/gems/money-1.7.1/lib/support/cattr_accessor.rb:5:in
`each'

from /usr/local/lib/ruby/gems/1.8/gems/money-1.7.1/lib/support/cattr_accessor.rb:5:in
`cattr_reader'

from /usr/local/lib/ruby/gems/1.8/gems/money-1.7.1/lib/support/cattr_accessor.rb:54:in
`cattr_accessor'

from /home/www/code.kid-safe.co.uk/code/releases/20080610212646/vendor/rails/activerecord/lib/active_record/base.rb:364

from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'

from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'

from /home/www/code.kid-safe.co.uk/code/releases/20080610212646/vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in
`require'

from /home/www/code.kid-safe.co.uk/code/releases/20080610212646/vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in
`new_constants_in'
... 40 levels...

from /home/www/code.kid-safe.co.uk/code/releases/20080610212646/vendor/rails/railties/lib/commands/server.rb:39

from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'

from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
from script/server:3


Any suggestions or help would be greatly appreciated. I am running
vendor/rails and everything else is working ok so the problem is certainly
the money gem or rails 2.1.0

best regards,
St.john
--
St.john Goldfinger
Managing Director
KidSafe Software LTD
 
Bridge Park, Gosforth
Newcastle upon Tyne
NE3 2DX, UK

Mobile: +44 (0)7799647824
Email: stj...@kid-safe.co.uk
Support: sup...@kid-safe.co.uk
Web: www.kid-safe.co.uk

alex_f

unread,
Jun 25, 2008, 5:54:23 PM6/25/08
to Active Merchant
I am using 1.7.1 with Rails 2.1, but haven't seen that problem. The
only problem I had was that the object wouldn't get 'dirty' when the
money field was updated, so I had to force money_field_will_change!
on before_save
good luck
Alex

On Jun 11, 10:01 am, stjohn goldfinger <stj...@kid-safe.co.uk> wrote:
> Hi,
> has anyone used the money 1.7.1 rails gem with vendor rails 2.1.0? I am having
> some problems getting it to work. It should be quite straight forward but
> when I require it in via my environment.rb and test it out with say
> script/server I get this:
>
> *****************myservrer..........
> => Booting Mongrel (use 'script/server webrick' to force WEBrick)
> => Rails 2.1.0 application starting onhttp://0.0.0.0:3000
> Support:  supp...@kid-safe.co.uk
> Web:www.kid-safe.co.uk

Ingemar

unread,
Jul 4, 2008, 11:30:25 AM7/4/08
to Active Merchant
Hello,

So you don't have any dirty money in yr bznz?? ;) Well, this greedy
ghetto hack might solve it...

Since I had a lot of models using Money gem I changed the (vendored)
gem instead of doing a lot of filtering.
(My first intention was to use ActiveRecord::Observer , but failed due
to some conflicts with Globalize or whatever)

In file "lib/aggregations.rb" after line #178 i added following line:

mapping.each{ |pair| self.send("#{pair.first}_will_change!") }

This should do the trick!
--- ingemar

LeviCole

unread,
Jul 9, 2008, 11:49:37 AM7/9/08
to Active Merchant
Hey guys,

I am actually having the same problem, the weird thing to me is that
it works fine on running thin and passenger but webrick and mongrel
crap out and wont start.

Levi

Josh

unread,
Jul 15, 2008, 11:38:46 PM7/15/08
to Active Merchant
> > In file "lib/aggregations.rb" after line #178  i added following line:
>
> >   mapping.each{ |pair| self.send("#{pair.first}_will_change!") }
>

------------------------------------------------------------------------------------------------
I actually made the above change but after further investigation, the
issues seems to be the patch level of ruby that you are running

I have a linux box running 1.8.6 patch level 114 -- released
2008-03-03 => broken with this error
I have a Mac running 1.8.6 patch level 114 -- released 2008-03-03 =>
broken with this error
I have another linux box running 1.8.6 patch level 111 -- released
2007-09-24 => Not Broken

I may be going in the wrong direction but this was the only difference
in the boxes

Josh Holt

Josh

unread,
Aug 7, 2008, 8:49:47 AM8/7/08
to Active Merchant
I have found the solution to this particular issue...

edit this file --> /usr/local/lib/ruby/gems/1.8/gems/money-1.7.1/lib/
support/cattr_accessor.rb

Change all the "sym.id2name" method calls to "sym.to_s"

to_s is an alias for id2name. For some reason this solves this
issue...

Mabey id2name has been deprecated!!

Let me know if this works for you as it did for me..

Thanks,

Josh Holt

Cody Fauser

unread,
Aug 7, 2008, 9:38:54 AM8/7/08
to activem...@googlegroups.com
Josh,

Thanks for looking into this. I'll ensure that this file gets updated
to a more current implementation of cattr_accessor.

--
Cody Fauser
http://shopify.com - e-commerce done right
http://www.codyfauser.com - blog
http://peepcode.com/products/activemerchant-pdf - ActiveMerchant PeepCode
http://www.oreilly.com/catalog/rjsrails - RJS Templates for Rails

Josh

unread,
Aug 7, 2008, 1:25:33 PM8/7/08
to Active Merchant
Cody,
No problem...
I just wish I had more time to get involved with this and other
projects..
but until then.. I will just settle for the occasional bug hunt! :)

Josh Holt
Reply all
Reply to author
Forward
0 new messages