Interesting. Looks like an issue.
Maybe it is related to how rails is loading undefined constants/classes.
Can you try just using plain Ruby classes without any inheritance from
Neo4j::Rails::Model
and see if the same problem occurs ?
Something like this:
biz_process.rb:
class BizProcess
end
innovation.rb:
class Innovation < BizProcess
puts Department
end
department.rb:
class Department
end
> --
> You received this message because you are subscribed to the Google Groups "neo4jrb" group.
> To post to this group, send email to neo...@googlegroups.com.
> To unsubscribe from this group, send email to neo4jrb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
>
>
If someone wants help out there are some bugs that needs to be fixed:
http://neo4j.lighthouseapp.com/projects/15548-neo4j/tickets
The easiest to solve is probably:
http://neo4j.lighthouseapp.com/projects/15548/tickets/183-init_on_create-is-not-called-when-creating-a-new-relationship-with-the-operator
/Andreas
I can't reproduce this bug and I'm therefore not sure it is a bug,
Here is what I did.
1. Create a new rails project
rails new qwe -m http://andreasronge.github.com/rails3.rb
2. Create the three model classes:
models/
|-- biz_process.rb
|-- department.rb
`-- innovation.rb
biz_process.rb:
class BizProcess < Neo4j::Rails::Model
property :title, :type => String
end
innovation.rb:
class Innovation < BizProcess
has_n(:deps).to(Department)
end
department.rb:
class Department < Neo4j::Rails::Model
property :name, :type => String
index :name
has_n(:innovations).from(Innovation, :deps)
end
4. Start the rails console: rails s
5. Type rails c
Loading development environment (Rails 3.1.0)
jruby-1.6.4 :001 > Innovation
=> Innovation
jruby-1.6.4 :002 > Innovation.create
Enable remote shell at port port=9332
Starting local Neo4j using db /home/andreas/tmp/qwe/db/neo4j-development
=> #<Innovation:0x3ee0b7 @errors=#<ActiveModel::Errors:0x1af431c
@base=#<Innovation:0x3ee0b7 ...>, @messages=#<OrderedHash {}>>,
@changed_attributes={}, @properties={"_classname"=>"Innovation"},
@_java_node=#<#<Class:0x1015fd4a3>:0x911b9f>, @relationships={},
@previously_changed={"_classname"=>[nil, "Innovation"]},
@validation_context=nil>
/Andreas
class Innovation < BizProcess
puts "Innovation #{Department}"
end
class BizProcess
puts "BizProcess #{Department}"
end
I suggest that you in the innovation.rb file does a forward
declaration of BizProcess
innovation.rb:
class BizProcess < Neo4j::Rails::Model
end
class Innovation ...
biz_process.rb:
# open up the BizProcess again and add all your properties and has_n etc...
Is that a good enough work around ?
/Andreas