Re: Issue with Spira has_many

Thanks for the suggestions.  I did try both of those, which failed as soon
as the ConceptScheme class is loaded.

On Tue, Feb 1, 2011 at 3:03 PM, Ben Lavender <blavender@gmail.com> wrote:

> You infer correctly that it's a class loader issue; I haven't tested
> Spira with rails. Danny is correct in that a more specific reference
> to the class is probably required.
>
> Ben
>
> On Tue, Feb 1, 2011 at 8:55 PM, Daniel Gagne <danny@dannygagne.com> wrote:
> > it looks like it can't find the symbol perhaps try
> >
> > type => :'OpenMedia::Schema::SKOS::Concept'
> >
> > or
> >
> > type => OpenMedia::Schema::SKOS::Concept
> >
> > danny
> >
> > On Tue, Feb 1, 2011 at 2:49 PM, Greg Lappen <greg@lapcominc.com> wrote:
> >> Hello again everyone,
> >> I am now attempting to do some integration of RDF with our Ruby on Rails
> >> application, and found the Spira project which I have to say is just
> awesome
> >> - it's a perfect fit for what we want to do.  I'm having a small problem
> >> though with getting relationships between our Spira resources to work.
>  I
> >> basically have one class, and it is going to "have many" of another
> class.
> >>  The subject matter happens to be SKOS concept and concept schemes.
>  Here's
> >> the basic code:
> >> in app/models/open_media/schema/skos/concept.rb:
> >> class OpenMedia::Schema::SKOS::Concept
> >>   include Spira::Resource
> >>
> >>   default_source :types
> >>   base_uri "http://data.openmedia.org/"
> >>   type SKOS.Concept
> >>   property :label, :predicate=>SKOS.label, :type=>XSD.string
> >> end
> >> in app/models/open_media/schema/skos/concept_scheme.rb:
> >> class OpenMedia::Schema::SKOS::ConceptScheme
> >>   include Spira::Resource
> >>
> >>   default_source :types
> >>   base_uri "http://data.openmedia.org/"
> >>   type SKOS.ConceptScheme
> >>   property :label, :predicate=>SKOS.prefLabel, :type=>XSD.string
> >>   has_many :top_concepts, :predicate=>SKOS.hasTopConcept,
> :type=>:Concept
> >> end
> >> So with the has_many type being the symbol :Concept, I get the following
> >> error:
> >> ArgumentError: OpenMedia::Schema::SKOS is not missing constant Concept!
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/activesupport-3.0.3/lib/active_support/dependencies.rb:479:in
> >> `load_missing_constant'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/activesupport-3.0.3/lib/active_support/dependencies.rb:183:in
> >> `const_missing'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/activesupport-3.0.3/lib/active_support/dependencies.rb:181:in
> >> `each'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/activesupport-3.0.3/lib/active_support/dependencies.rb:181:in
> >> `const_missing'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/spira-0.0.11/lib/spira/resource/dsl.rb:209:in
> >> `const_get'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/spira-0.0.11/lib/spira/resource/dsl.rb:209:in
> >> `qualified_const_get'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/rdf-0.3.1/lib/rdf/ntriples/reader.rb:184:in
> >> `inject'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/spira-0.0.11/lib/spira/resource/dsl.rb:209:in
> >> `each'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/spira-0.0.11/lib/spira/resource/dsl.rb:209:in
> >> `inject'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/spira-0.0.11/lib/spira/resource/dsl.rb:209:in
> >> `qualified_const_get'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/spira-0.0.11/lib/spira/resource/dsl.rb:178:in
> >> `classize_resource'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/spira-0.0.11/lib/spira/resource/dsl.rb:142:in
> >> `build_value'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/spira-0.0.11/lib/spira/resource/instance_methods.rb:91:in
> >> `reload_attributes'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/rdf-0.3.1/lib/rdf/mixin/queryable.rb:70:in
> >> `each'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/rdf-0.3.1/lib/rdf/mixin/queryable.rb:70:in
> >> `grep'
> >> from
> >> /Users/greg/.rvm/gems/ree-1.8.7-2010.02@openmedia
> /gems/rdf-0.3.1/lib/rdf/mixin/queryable.rb:70:in
> >> `each'
> >> Without the relationship between them, both classes work great.  Am I
> right
> >> in thinking it's a disagreement between Rails class loading mechanism
> and
> >> how Spira is trying to load the has_many type?  I can reference
> >> OpenMedia::Schema::SKOS::Concept fine in rails console, but as soon as I
> >> save the concept scheme with a concept in the has_many, I get this
> error.
> >>  Any ideas?  I was prepared to fix this and submit a patch, but an hour
> >> later, no such luch.  Thanks!
> >> Greg
> >
> >
>

Received on Tuesday, 1 February 2011 20:10:24 UTC