Undefined read_methods for 0.9.0 on Rails 2.0 preview...

24 views
Skip to first unread message

DeRailed

unread,
Oct 17, 2007, 11:33:52 AM10/17/07
to Composite Keys for ActiveRecord
Hi Nick,

I am trying to use the plugin in rails 2.0 preview mode and I am
getting the following error:

(undefined method `read_methods' for #<Class:0x33a421c>)
vendor/rails/activerecord/lib/active_record/base.rb:1282:in
`method_missing'
/usr/local/lib/ruby/gems/1.8/gems/composite_primary_keys-0.9.0/lib/
composite_primary_keys/base.rb:110:in `method_missing'

Any ideas ?

Thanks,
Fernand

Nic Williams

unread,
Oct 17, 2007, 5:29:22 PM10/17/07
to compos...@googlegroups.com
Unfortunately I'm having some net problems and haven't run the CPK tests against 2.0pre nor edge rails in a while.

Can someone else install 2.0 and run 'rake test_mysql'?

On 10/18/07, DeRailed <fernand...@gmail.com> wrote:

Hi Nick,

   I am trying to use the plugin in rails 2.0 preview mode and I am
getting the following error:

   (undefined method `read_methods' for #<Class:0x33a421c>)
    vendor/rails/activerecord/lib /active_record/base.rb:1282:in

`method_missing'
  /usr/local/lib/ruby/gems/1.8/gems/composite_primary_keys-0.9.0/lib/
composite_primary_keys/base.rb:110:in `method_missing'

   Any ideas ?

Thanks,
Fernand



http://drnicacademy.com - Ruby/Rails training around the world
http://drnicwilliams.com - Ruby/Rails/Javascript/Web2.0
skype: nicwilliams
(p) +61 412 002 126
(mail) PO Box 583, Ashgrove 4060, Queensland, Australia

Daniel

unread,
Oct 19, 2007, 11:30:02 PM10/19/07
to Composite Keys for ActiveRecord
Just confirming this is not an isolated issue - I'm getting it too.

I don't seem to have test_mysql for rake, either, or I'd post the
results, but I can give you a little bit of information: the results
of a debug session where I got the same error. Not sure how useful it
is, but the stack trace might be able to point you in the right
direction.

irb(#<UsersController:0x565a5b8>):158:0* @ar_join_object
=> #<UserAccount account_id: 1, user_id: 1, points: 3, created_at:
"2007
-10-20 13:05:27", updated_at: "2007-10-20 13:05:27">
irb(#<UsersController:0x565a5b8>):159:0> @ar_join_object.points
NoMethodError: undefined method `read_methods' for #<Class:0x55c4a18>
from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/
lib/active_
record/base.rb:1303:in `method_missing'
from c:/ruby/lib/ruby/gems/1.8/gems/
composite_primary_keys-0.9.0/lib/com
posite_primary_keys/base.rb:110:in `method_missing'
from (irb):159:in `call_filters'
from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5.7919/lib/
action_co
ntroller/base.rb:1131:in `call_filters'
from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5.7919/lib/
action_co
ntroller/filters.rb:689:in `perform_action_without_benchmark'
from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5.7919/lib/
action_co
ntroller/benchmarking.rb:68:in `perform_action_without_rescue'
from c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5.7919/lib/
action_co
ntroller/benchmarking.rb:68:in `perform_action_without_rescue'
from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5.7919/lib/
action_co
ntroller/rescue.rb:175:in `perform_action_without_caching'
from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5.7919/lib/
action_co
ntroller/caching.rb:670:in `perform_action'
from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/
lib/active_
record/connection_adapters/abstract/query_cache.rb:33:in `cache'
from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/
lib/active_
record/query_cache.rb:8:in `cache'
from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5.7919/lib/
action_co
ntroller/caching.rb:669:in `perform_action'
from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5.7919/lib/
action_co
ntroller/base.rb:517:in `send'
from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5.7919/lib/
action_co
ntroller/base.rb:517:in `process_without_filters'
from c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.5.7919/lib/
action_co
ntroller/filters.rb:685:in
`process_without_session_management_support'
... 23 levels...
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/lib/
mongrel/co
mmand.rb:211:in `run'
from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.0.1-mswin32/bin/
mongrel_ra
ils:243
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4.7919/
lib/active_
support/dependencies.rb:489:in `load'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4.7919/
lib/active_
support/dependencies.rb:489:in `load'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4.7919/
lib/active_
support/dependencies.rb:342:in `new_constants_in'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4.7919/
lib/active_
support/dependencies.rb:489:in `load'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.5.7919/lib/
commands/server
s/mongrel.rb:64
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `ge
m_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `re
quire'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4.7919/
lib/active_
support/dependencies.rb:496:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4.7919/
lib/active_
support/dependencies.rb:342:in `new_constants_in'
from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4.7919/
lib/active_
support/dependencies.rb:496:in `require'
from c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.5.7919/lib/
commands/server
.rb:39
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `ge
m_original_require'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
27:in `re
quire'
from script/server:3irb(#<UsersController:0x565a5b8>):160:0>
(rdb:5)

(rdb:5) ** INT signal received.


On Oct 18, 7:29 am, "Nic Williams" <drnicwilli...@gmail.com> wrote:
> Unfortunately I'm having some net problems and haven't run the CPK tests
> against 2.0pre nor edge rails in a while.
> Can someone else install 2.0 and run 'rake test_mysql'?
>

> On 10/18/07, DeRailed <fernand.gali...@gmail.com> wrote:
>
>
>
>
>
> > Hi Nick,
>
> > I am trying to use the plugin in rails 2.0 preview mode and I am
> > getting the following error:
>
> > (undefined method `read_methods' for #<Class:0x33a421c>)

> > vendor/rails/activerecord/lib/active_record/base.rb:1282:in


> > `method_missing'
> > /usr/local/lib/ruby/gems/1.8/gems/composite_primary_keys-0.9.0/lib/
> > composite_primary_keys/base.rb:110:in `method_missing'
>
> > Any ideas ?
>
> > Thanks,
> > Fernand
>

> --
> Dr Nic Williamshttp://drnicacademy.com- Ruby/Rails training around the worldhttp://drnicwilliams.com- Ruby/Rails/Javascript/Web2.0

Xavier Shay

unread,
Oct 23, 2007, 1:33:03 AM10/23/07
to Composite Keys for ActiveRecord
I get this problem as well. Suspect the following changeset is to
blame:
http://dev.rubyonrails.org/changeset/7315

It moves a whole heap of stuff (inc method_missing) that is monkey
patched in CPK.
That code (both AR and CPK) is a bit voodoo to me, so I'm not sure
what's going on.
Trying to get CPK tests running now...

Xavier

Xavier Shay

unread,
Oct 23, 2007, 1:42:08 AM10/23/07
to Composite Keys for ActiveRecord
I blanked out the pagination tests because they're not valid anymore

~/Code/composite_keys_trunk_clean/trunk> rake test_mysql
(in /Users/xavier/Code/composite_keys_trunk_clean/trunk)
/opt/local/bin/ruby -Ilib:test:test/connections/native_mysql "/opt/
local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb"
"test/test_associations.rb" "test/test_attributes.rb" "test/
test_clone.rb" "test/test_create.rb" "test/test_delete.rb" "test/
test_dummy.rb" "test/test_find.rb" "test/test_ids.rb" "test/
test_miscellaneous.rb" "test/test_pagination.rb" "test/
test_polymorphic.rb" "test/test_santiago.rb" "test/
test_tutorial_examle.rb" "test/test_update.rb"
Using native MySQL
Logging to /Users/xavier/Code/composite_keys_trunk_clean/trunk/log/
debug.log
Loaded suite /opt/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/
rake_test_loader
Started
...................E....FF./test/test_delete.rb:46: warning: Object#id
will be deprecated; use Object#object_id
E./test/test_delete.rb:52: warning: Object#id will be deprecated; use
Object#object_id
E../test/test_delete.rb:40: warning: Object#id will be deprecated; use
Object#object_id
E./test/test_delete.rb:34: warning: Object#id will be deprecated; use
Object#object_id
E.EEF.F./test/test_ids.rb:29: warning: Object#id will be deprecated;
use Object#object_id
E./test/test_ids.rb:35: warning: Object#id will be deprecated; use
Object#object_id
FF.EEE.E..........E
Finished in 0.299278 seconds.

1) Error:
test_create(TestCreate):
ActiveRecord::ProtectedAttributeAssignmentError: Can't mass-assign
these protected attributes: reference_type_id
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/lib/
active_record/base.rb:2056:in
`remove_attributes_protected_from_mass_assignment'
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/lib/
active_record/base.rb:1858:in `attributes='
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/lib/
active_record/base.rb:1685:in `initialize'
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/lib/
active_record/base.rb:467:in `new'
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/lib/
active_record/base.rb:467:in `create'
./test/test_create.rb:33:in `test_create'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_create.rb:32:in `test_create'

2) Failure:
test_delete_association(TestDelete) [./test/test_delete.rb:80]:
Employee count for department should be 2 before delete.
<2> expected but was
<0>.

3) Failure:
test_delete_many(TestDelete)
[./test/test_delete.rb:59:in `test_delete_many'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_delete.rb:57:in `test_delete_many']:
<2> expected but was
<0>.

4) Error:
test_delete_one(TestDelete):
IndexError: element size differs (1 should be 2)
./lib/composite_primary_keys/base.rb:214:in `transpose'
./lib/composite_primary_keys/base.rb:214:in `delete'
./lib/composite_primary_keys/base.rb:213:in `map'
./lib/composite_primary_keys/base.rb:213:in `delete'
./test/test_delete.rb:46:in `test_delete_one'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_delete.rb:45:in `test_delete_one'

5) Error:
test_delete_one_alone(TestDelete):
IndexError: element size differs (1 should be 2)
./lib/composite_primary_keys/base.rb:214:in `transpose'
./lib/composite_primary_keys/base.rb:214:in `delete'
./lib/composite_primary_keys/base.rb:213:in `map'
./lib/composite_primary_keys/base.rb:213:in `delete'
./test/test_delete.rb:52:in `test_delete_one_alone'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_delete.rb:51:in `test_delete_one_alone'

6) Error:
test_destroy_one_alone_via_class(TestDelete):
RuntimeError: [4]: Incorrect number of primary keys for ReferenceCode:
[:reference_type_id, :reference_code]
./lib/composite_primary_keys/base.rb:286:in `find_from_ids'
./lib/composite_primary_keys/base.rb:281:in `each'
./lib/composite_primary_keys/base.rb:281:in `find_from_ids'
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/lib/
active_record/base.rb:437:in `find'
./lib/composite_primary_keys/base.rb:230:in `destroy'
./test/test_delete.rb:40:in `test_destroy_one_alone_via_class'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_delete.rb:39:in `test_destroy_one_alone_via_class'

7) Error:
test_destroy_one_via_class(TestDelete):
RuntimeError: [4]: Incorrect number of primary keys for ReferenceCode:
[:reference_type_id, :reference_code]
./lib/composite_primary_keys/base.rb:286:in `find_from_ids'
./lib/composite_primary_keys/base.rb:281:in `each'
./lib/composite_primary_keys/base.rb:281:in `find_from_ids'
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/lib/
active_record/base.rb:437:in `find'
./lib/composite_primary_keys/base.rb:230:in `destroy'
./test/test_delete.rb:34:in `test_destroy_one_via_class'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_delete.rb:33:in `test_destroy_one_via_class'

8) Error:
test_find(TestFind):
ActiveRecord::RecordNotFound: Couldn't find all ReferenceCodes with
IDs ([[1, 1]])reference_codes.reference_type_id=1 AND
reference_codes.reference_code=1
./lib/composite_primary_keys/base.rb:309:in `find_from_ids'
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/lib/
active_record/base.rb:437:in `find'
./test/test_find.rb:38:in `test_find'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_find.rb:37:in `test_find'

9) Error:
test_find_composite_ids(TestFind):
ActiveRecord::RecordNotFound: Couldn't find all ReferenceCodes with
IDs ([[1, 1]])reference_codes.reference_type_id=1 AND
reference_codes.reference_code=1
./lib/composite_primary_keys/base.rb:309:in `find_from_ids'
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5.7919/lib/
active_record/base.rb:437:in `find'
./test/test_find.rb:48:in `test_find_composite_ids'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_find.rb:47:in `test_find_composite_ids'

10) Failure:
test_find_first(TestFind)
[./test/test_find.rb:31:in `test_find_first'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_find.rb:29:in `test_find_first']:
<nil> is not true.

11) Failure:
test_to_param(TestFind)
[./test/test_find.rb:58:in `test_to_param'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_find.rb:57:in `test_to_param']:
<"1,1"> expected but was
<"">.

12) Error:
test_id(TestIds):
NoMethodError: undefined method `ids' for nil:NilClass
./test/test_ids.rb:29:in `test_id'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_ids.rb:28:in `test_id'

13) Failure:
test_id_to_s(TestIds)
[./test/test_ids.rb:35:in `test_id_to_s'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_ids.rb:34:in `test_id_to_s']:
<"1,1"> expected but was
<"4">.

14) Failure:
test_ids_to_s(TestIds)
[./test/test_ids.rb:44:in `test_ids_to_s'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_ids.rb:41:in `test_ids_to_s']:
<"(1,1),(1,2)"> expected but was
<"">.

15) Error:
test_set_ids_array(TestIds):
NoMethodError: undefined method `id=' for nil:NilClass
./test/test_ids.rb:62:in `test_set_ids_array'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_ids.rb:59:in `test_set_ids_array'

16) Error:
test_set_ids_comp(TestIds):
NoMethodError: undefined method `id=' for nil:NilClass
./test/test_ids.rb:71:in `test_set_ids_comp'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_ids.rb:68:in `test_set_ids_comp'

17) Error:
test_set_ids_string(TestIds):
NoMethodError: undefined method `id=' for nil:NilClass
./test/test_ids.rb:53:in `test_set_ids_string'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_ids.rb:50:in `test_set_ids_string'

18) Error:
test_composite_instance(TestMiscellaneous):
NoMethodError: undefined method `composite?' for nil:NilClass
./test/test_miscellaneous.rb:31:in `test_composite_instance'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_miscellaneous.rb:30:in `test_composite_instance'

19) Error:
test_update_attributes(TestUpdate):
NoMethodError: undefined method `update_attributes' for nil:NilClass
./test/test_update.rb:33:in `test_update_attributes'
./test/abstract_unit.rb:65:in `testing_with'
./test/abstract_unit.rb:60:in `each'
./test/abstract_unit.rb:60:in `testing_with'
./test/test_update.rb:32:in `test_update_attributes'

57 tests, 144 assertions, 6 failures, 13 errors

Sam Lown

unread,
Nov 8, 2007, 1:33:01 PM11/8/07
to Composite Keys for ActiveRecord
Is there any news on this yet, as I'm having similar problems.

Cheers, sam

Nic Williams

unread,
Nov 8, 2007, 5:08:56 PM11/8/07
to compos...@googlegroups.com
I haven't had/made time to look at this. I've been on the RubiGen
crusade recently @ RubyConf.

Come on team, some interested into hunting down this defect?

Tally-ho!

Nic

On 11/9/07, Sam Lown <sam....@gmail.com> wrote:
>
> Is there any news on this yet, as I'm having similar problems.
>
> Cheers, sam
>
>
> >
>


--
Dr Nic Williams
http://drnicacademy.com - Ruby/Rails training/dev around the world
http://drnicwilliams.com - Ruby/Rails/Javascript/Web2.0
(skype) nicwilliams
(p) +61 412 002 126 / +61 7 3113 3033
(mail) PO Box 583 Ashgrove 4060 QLD Aus

darrin

unread,
Nov 9, 2007, 10:18:17 AM11/9/07
to Composite Keys for ActiveRecord
Here you go, what do I win?

http://compositekeys.googlegroups.com/web/fix_tests.patch

The new fixture caching that was put in to 2.0 made this bug shine
through. The problem was that setup_with_fixtures never got past the
first check in fixtures.rb...

return unless defined?(ActiveRecord::Base) && !
ActiveRecord::Base.configurations.blank?

...due to ActiveRecord::Base.configurations always being blank. That
is why the fixture method in the tests never worked and you had to
explicitly call create_fixtures in each test setup. I changed
load_connection_from_env to set the ActiveRecord::Base.configurations
based on the 'cpk_adapters' variable and all was well. I'm not exactly
sure why the create_fixtures call in each test and the caching broke
things, nor do I really care since now the tests/fixtures behave like
they are supposed to.

I've only tested this with Oracle on rails 1.2.2 and 2.0.0_PR.

Darrin

On Nov 8, 4:08 pm, "Nic Williams" <drnicwilli...@gmail.com> wrote:
> I haven't had/made time to look at this. I've been on the RubiGen
> crusade recently @ RubyConf.
>
> Come on team, some interested into hunting down this defect?
>
> Tally-ho!
>
> Nic
>

> On 11/9/07, Sam Lown <sam.l...@gmail.com> wrote:
>
>
>
> > Is there any news on this yet, as I'm having similar problems.
>
> > Cheers, sam
>
> --

> Dr Nic Williamshttp://drnicacademy.com- Ruby/Rails training/dev around the worldhttp://drnicwilliams.com- Ruby/Rails/Javascript/Web2.0

darrin

unread,
Nov 9, 2007, 10:30:21 AM11/9/07
to Composite Keys for ActiveRecord
I guess I should clarify that I just fixed the tests for 2.0 pre. I'm
not sure if there is a problem as it pertains to the original post, if
there is I'll take a look at it if someone posts or sends me a failing
test.

Thanks,
Darrin

Andrew

unread,
Dec 14, 2007, 6:16:11 PM12/14/07
to Composite Keys for ActiveRecord
Hi darrin,

How can I apply this patch to the gem? Or will the gem be updated any
time soon with this patch applied?

Thanks for solving.
Andrew
> > > Dr Nic Williamshttp://drnicacademy.com-Ruby/Railstraining/dev around the worldhttp://drnicwilliams.com-Ruby/Rails/Javascript/Web2.0

Nic Williams

unread,
Dec 14, 2007, 11:47:24 PM12/14/07
to compos...@googlegroups.com
I'm not able to run the patch:

patch -p0 < fix_tests.patch

rejects most file changes :(

Darrin, what;s your rubyforge account and I'll add you to the project so you can commit it directly.

Cheers and great work (assuming all our hopes and dreams have been answered!) :)

Nic

http://drnicacademy.com - Ruby/Rails training/dev around the world
http://drnicwilliams.com - Ruby/Rails/Javascript/Web2.0

darrin

unread,
Dec 18, 2007, 8:33:52 AM12/18/07
to Composite Keys for ActiveRecord
hmmm, that's weird, I was able to apply the patch. Oh well, my
rubyforge user id is darrinholst.

Darrin
> --
> Dr Nic Williamshttp://drnicacademy.com- Ruby/Rails training/dev around the worldhttp://drnicwilliams.com- Ruby/Rails/Javascript/Web2.0

Nic Williams

unread,
Dec 18, 2007, 4:39:04 PM12/18/07
to compos...@googlegroups.com
It doubles as a good excuse to start adding project committers and giving the project fresh life.

Darrin - you've been added now.

Nic
--
Dr Nic Williams

http://drnicacademy.com - Ruby/Rails training/dev around the world
http://drnicwilliams.com - Ruby/Rails/Javascript/Web2.0

Rich C

unread,
Dec 19, 2007, 6:19:45 PM12/19/07
to Composite Keys for ActiveRecord

It looks like the patch listed above is mainly to get the unit tests
running again. Has anyone looked at what needs to be done to fix the
error?

>> x.AMTRMIT
NoMethodError: undefined method `read_methods' for #<Class:0x1a1cac4>
from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/base.rb:1532:in `method_missing'
from /opt/local/lib/ruby/gems/1.8/gems/composite_primary_keys-0.9.0/
lib/composite_primary_keys/base.rb:110:in `method_missing'
from (irb):5

I just got this error this afternoon when updating an app from 1.2.x
to 2.0.2. I sure don't mind looking into it, but honestly not sure if
I have the kung-fu to figure it out...

darrin

unread,
Dec 19, 2007, 8:40:37 PM12/19/07
to Composite Keys for ActiveRecord
woo hoo...first rubyforge commit!

All tests are now passing against 2.0.2 (mysql).

As for the original error that started this thread...there isn't a
test that exposes this error...so if someone could post a failing
test, I'd be more than happy to take a look at it.

Darrin

Nic Williams

unread,
Dec 19, 2007, 9:25:01 PM12/19/07
to compos...@googlegroups.com
Congratulations! OSS glory awaits!:)

Look in the Files section and recent emails for some patches that included failing tests, I think.

I just ran the mysql and sqlite tests and there is one failure (different) for each.

SQLITE:
test_count(TestAssociations):
ActiveRecord::StatementInvalid: SQLite3::SQLException: wrong number of arguments to function count(): SELECT count(DISTINCT tariffs.tariff_id,tariffs.start_date) AS count_all FROM tariffs  LEFT OUTER JOIN product_tariffs ON (product_tariffs.tariff_id= tariffs.tariff_id AND product_tariffs.tariff_start_date=tariffs.start_date)   
 
MYSQL:
test_delete_association(TestDelete) [./test/test_delete.rb:80]:
Employee count for department should be 2 before delete.
<2> expected but was
<0>.


darrin

unread,
Dec 19, 2007, 10:13:38 PM12/19/07
to Composite Keys for ActiveRecord
The test_delete_association one was a tricky one...

short answer: rake mysql:rebuild_databases

long answer: With use_transactional_fixtures = true a transaction will
be wrapped around each test and rolled back at the end of the test to
isolate them from changes that other test methods may make (like the
test right before test_delete_association). The one caveat is that
your database must support transactions, the default table format for
MySql(MyISAM) does not, however the InnoDB type does. A few tables in
the MySql script didn't include TYPE=InnoDB on the create. I'd like to
take credit for coming up with that off of the top of my head, but I
needed a little Google assistance - http://clarkware.com/cgi/blosxom/2005/10/24


The sqlite error sounds like the adapter needs a

def supports_count_distinct? #:nodoc:
false
end

like oracle_adapter, but it's getting too late to start installing a
new database to verify that.

On Dec 19, 8:25 pm, "Nic Williams" <drnicwilli...@gmail.com> wrote:
> Congratulations! OSS glory awaits!:)
> Look in the Files section and recent emails for some patches that included
> failing tests, I think.
>
> I just ran the mysql and sqlite tests and there is one failure (different)
> for each.
>
> SQLITE:
> test_count(TestAssociations):
> ActiveRecord::StatementInvalid: SQLite3::SQLException: wrong number of
> arguments to function count(): SELECT count(DISTINCT tariffs.tariff_id,
> tariffs.start_date) AS count_all FROM tariffs LEFT OUTER JOIN
> product_tariffs ON (product_tariffs.tariff_id=tariffs.tariff_id AND
> product_tariffs.tariff_start_date=tariffs.start_date)
>
> MYSQL:
> test_delete_association(TestDelete) [./test/test_delete.rb:80]:
> Employee count for department should be 2 before delete.
> <2> expected but was
> <0>.
>
> On Dec 20, 2007 11:40 AM, darrin <darrin.ho...@gmail.com> wrote:
>
>
>
>
>
> > woo hoo...first rubyforge commit!
>
> > All tests are now passing against 2.0.2 (mysql).
>
> > As for the original error that started this thread...there isn't a
> > test that exposes this error...so if someone could post a failing
> > test, I'd be more than happy to take a look at it.
>
> > Darrin
>
> > On Dec 19, 5:19 pm, Rich C <conejo2...@gmail.com> wrote:
> > > It looks like the patch listed above is mainly to get the unit tests
> > > running again. Has anyone looked at what needs to be done to fix the
> > > error?
>
> > > >> x.AMTRMIT
>
> > > NoMethodError: undefined method `read_methods' for #<Class:0x1a1cac4>
> > > from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
> > > active_record/base.rb:1532:in `method_missing'
> > > from /opt/local/lib/ruby/gems/1.8/gems/composite_primary_keys-
> > 0.9.0/
> > > lib/composite_primary_keys/base.rb:110:in `method_missing'
> > > from (irb):5
>
> > > I just got this error this afternoon when updating an app from 1.2.x
> > > to 2.0.2. I sure don't mind looking into it, but honestly not sure if
> > > I have the kung-fu to figure it out...
>
> --
> Dr Nic Williamshttp://drnicacademy.com- Ruby/Rails training/dev around the worldhttp://drnicwilliams.com- Ruby/Rails/Javascript/Web2.0

osmedd

unread,
Dec 21, 2007, 11:56:46 AM12/21/07
to Composite Keys for ActiveRecord
I see the original error in my code also (rails 2.0.1) when trying to
access fields in my models that use composite primary keys. I'm
upgrading to 2.0.2 now, though I expect to continue to see those
errors. Has anyone written a test yet to replicate this? I'm highly
motivated but haven't dived into activerecord internals at all, so I'm
not sure how hard it will be for me to do this. A complicating factor
I have in my code is the presence of will_paginate, which seems to
inject itself in there somehow also. Lol... can't have anything be
TOO easy, I suppose!

Owen

darrin

unread,
Dec 21, 2007, 1:31:07 PM12/21/07
to Composite Keys for ActiveRecord
Ok, I see where my misunderstanding is, the error occurs on attribute
access, not on a finder method. Xavier was right, changeset 7315
changed some stuff around that we'll need to fix.

Darrin

osmedd

unread,
Dec 21, 2007, 7:07:56 PM12/21/07
to Composite Keys for ActiveRecord
Anything I can help with? I've been around the block a few times,
just new to the Rails world.

darrin

unread,
Dec 24, 2007, 3:27:12 PM12/24/07
to Composite Keys for ActiveRecord
Just committed a fix for this. For those interested pull down the
latest from the repository and 'rake local_deploy' to test it out.
Thanks.

Darrin

gdelfino

unread,
Dec 26, 2007, 9:55:58 AM12/26/07
to Composite Keys for ActiveRecord
Hello all. I have just tested this change and it solved the "undefined
method `read_methods'" for me.

For the record, before running 'rake local_deploy' I had to do this:

$ svn checkout svn://rubyforge.org/var/svn/compositekeys/trunk
$ cd trunk
$ sudo gem install hoe --include-dependencies
$ sudo gem install syntax --include-dependencies
$ mkdir tmp

Then create and run this ruby program:
require 'rubygems'
require 'sqlite3'
db = SQLite3::Database.new('./tmp/test.db')

And finally:

$ rake --trace local_deploy

Regards,

Gustavo Delfino

Nic Williams

unread,
Dec 26, 2007, 5:00:09 PM12/26/07
to compos...@googlegroups.com
Do we still have outstanding defects for CPK on Rails 2.0? or can we release a new gem version?

Nic

On Dec 27, 2007 12:55 AM, gdelfino < gdel...@gmail.com> wrote:

Hello all. I have just tested this change and it solved the "undefined
method `read_methods'" for me.

For the record, before running 'rake local_deploy' I had to do this:

$ svn checkout svn://rubyforge.org/var/svn/compositekeys/trunk
$ cd trunk
$ sudo gem install hoe --include-dependencies
$ sudo gem install syntax --include-dependencies
$ mkdir tmp

Then create and run this ruby program:
require 'rubygems'
require 'sqlite3'
db = SQLite3::Database.new('./tmp/test.db')

And finally:

$ rake --trace local_deploy

Regards,

Gustavo Delfino

lsp

unread,
Dec 28, 2007, 8:57:54 AM12/28/07
to Composite Keys for ActiveRecord
Yes, we still have defects.
Steps to repeat:

1. sql:

create table `my_records` (
`first_id` int(10) unsigned not null,
`second_id` int(10) unsigned not null,
`first_field` time,
`second_field` bool,

primary key (`first_id`, `second_id`)
) engine=InnoDB character set=utf8;

insert into my_records values (1, 1, '20:07', true);

2. ruby:

require 'composite_primary_keys'
class MyRecord < ActiveRecord::Base
set_primary_keys [:first_id, :second_id]
end

f = MyRecord.find :all

f.first.first_id
=> 1

f.first.second_id
=> 1

f.first.first_field
=>
NameError: uninitialized constant
CompositePrimaryKeys::ActiveRecord::ConnectionAdapters
from f:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
active_support/dependencies.rb:2
66:in `load_missing_constant'
from f:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
active_support/dependencies.rb:4
53:in `const_missing'
from X:/Work/MyApp/vendor/plugins/compositekeys/lib/
composite_primary_keys/attribute_methods.rb:33:in `first_field'
from (irb):7



This error appear
for :decimal, :datetime, :timestamp, :time, :date, :binary
and :boolean field types, because in
compositekeys/lib/composite_primary_keys/attribute_methods.rb:12
cast_code = column.type_cast_code('v') if column
the value of cast_code after type_cast_code call is
'ActiveRecord::ConnectionAdapters::MysqlColumn.string_to_dummy_time(v)'

But If we set the value of cast_code to
'::ActiveRecord::ConnectionAdapters::MysqlColumn.string_to_dummy_time(v)'
all work fine.
The diff is in the global namespace prefix "::"

Function type_cast_code defined in
ActiveRecord::ConnectionAdapters::Column as
def type_cast_code(var_name)
case type
when :string then nil
when :text then nil
when :integer then "(#{var_name}.to_i rescue #{var_name} ?
1 : 0)"
when :float then "#{var_name}.to_f"
when :decimal then
"#{self.class.name}.value_to_decimal(#{var_name})"
when :datetime then
"#{self.class.name}.string_to_time(#{var_name})"
when :timestamp then
"#{self.class.name}.string_to_time(#{var_name})"
when :time then
"#{self.class.name}.string_to_dummy_time(#{var_name})"
when :date then
"#{self.class.name}.string_to_date(#{var_name})"
when :binary then
"#{self.class.name}.binary_to_string(#{var_name})"
when :boolean then
"#{self.class.name}.value_to_boolean(#{var_name})"
else nil
end
end

I don`t know what is the best way to fix this problem.
Is this bug in Rails or in CPK?
Can we override this function in CPK?


WBR,
Leonid S. Pavlov


On Dec 27, 1:00 am, "Nic Williams" <drnicwilli...@gmail.com> wrote:
> Do we still have outstanding defects for CPK on Rails 2.0? or can we release
> a new gem version?
> Nic
>
> --
> Dr Nic Williamshttp://drnicacademy.com- Ruby/Rails training/dev around the worldhttp://drnicwilliams.com- Ruby/Rails/Javascript/Web2.0

darrin

unread,
Dec 28, 2007, 11:55:08 AM12/28/07
to Composite Keys for ActiveRecord
Nice catch. This appears to be a problem with the cpk code running in
the CompositePrimaryKeys namespace. A quick and dirty way to fix it
would be to prepend a '::' to the cast_code if it started with
'ActiveRecord::'. Is there a better way to fix it?
> > Dr Nic Williamshttp://drnicacademy.com-Ruby/Rails training/dev around the worldhttp://drnicwilliams.com-Ruby/Rails/Javascript/Web2.0

darrin

unread,
Jan 10, 2008, 12:25:43 AM1/10/08
to Composite Keys for ActiveRecord
The latest on the trunk has the fix. Let us know of any other
problems.

Darrin
> > > Dr Nic Williamshttp://drnicacademy.com-Ruby/Railstraining/dev around the worldhttp://drnicwilliams.com-Ruby/Rails/Javascript/Web2.0

Dominio

unread,
Jan 25, 2008, 6:34:59 PM1/25/08
to Composite Keys for ActiveRecord
Will a new version with this fix get committed into the gem repository
soon? Or otherwise, how can I get this fix to properly install itself
on a windows system where all rails components have been installed
using gem?

Nic Williams

unread,
Jan 27, 2008, 2:46:18 AM1/27/08
to compos...@googlegroups.com
I've just released 0.9.90 as a trial release for rails 2.0.2 compatibility.

Let use know of any failing use cases.

Cheers
Nic

http://drnicwilliams.com - Ruby/Rails/Javascript/Web2.0

Steve Sims

unread,
Jan 27, 2008, 6:02:22 PM1/27/08
to Composite Keys for ActiveRecord
This new release is good news indeed!

Unfortunately as I mentioned in a separate email, there is a problem
in using composite key records in place of regular single-key records
when using Rails 2 URL helpers. A standard Rails 2 scaffold will
build a URLs such as this:
<%= link_to 'Show', product %>

If you try that with a "product" record that has a composite primary
key you will get an error page back, as described in my previous
email.

The work-around I discovered is to be much more explicit/verbose, and
use something like this:
<%= link_to 'Show', { :action => "show", :id => product } %>

This also does not work for me:
<% form_for(@product) do |f| %>

It produces an identical error message, which implies to me that it is
a related error, although this time the stacktrace does not include
composite_primary_keys.

Now I worked out a partial work-around for this form_for problem which
would display the form with the correct values inside it but when I
attempt to submit the form I get an error saying "Only get, put, and
delete requests are allowed." I suspect that's caused by a flaw in my
work-around, rather than being a related bug.

Fortunately for me this isn't currently a show-stopper - there are
other ways I can work around this problem where I've run into it.

Seems *really* close guys!

Keep up the good work!

Steve

On Jan 27, 7:46 am, "Nic Williams" <drnicwilli...@gmail.com> wrote:
> I've just released 0.9.90 as a trial release for rails 2.0.2 compatibility.
> Let use know of any failing use cases.
>
> Cheers
> Nic
>
> On 1/26/08, Dominio <ludvig.svenon...@gmail.com> wrote:
>
>
>
> > Will a new version with this fix get committed into the gem repository
> > soon? Or otherwise, how can I get this fix to properly install itself
> > on a windows system where all rails components have been installed
> > using gem?
>
> --
> Dr Nic Williamshttp://drnicacademy.com- Ruby/Rails training/dev around the worldhttp://drnicwilliams.com- Ruby/Rails/Javascript/Web2.0
Reply all
Reply to author
Forward
0 new messages