I installed has_many_polymorphs plugin in a freshly generated Radiant
application. Then I generated a simple Person-Disk-Book example models
(with script/generate extension_model), declared the polymorphic
associations as explained in many plugin tutorials, and put some test
data into the database. Then I get this strange behavior in the
script/console:
xonmac:~/Development/labs/radiant/mycms skozlov$ ./script/console
Loading development environment.
has_many_polymorphs: has_many_polymorphs: Rails environment detected
>> b = Book.find :first
=> #<Book:0x3456f48 @attributes={"id"=>"1"}>
>> b.people
NoMethodError: undefined method `people' for #<Book:0x3456f48
@attributes={"id"=>"1"}>
from
/opt/local/lib/ruby/gems/1.8/gems/radiant-0.6.2/vendor/rails/activerecord/lib/active_record/base.rb:1860:in
`method_missing'
from (irb):2
>> p = Person.find :first
=> #<Person:0x3411d08 @attributes={"id"=>"1"}>
>> b.people
=> []
To wrap it up: the "Book" class doesn't have the "people" method defined
until I do the a "find" on class Person. After that all works normally.
Direct associations (Person -> Book/Disk) work always fine.
This problem is not reproducible with a "normal" Rails application. In
case of any interest, I will be willing to put the whole application
source tree somewhere on the Internet.
I would appreciate any help with fixing this issue.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant