Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linked_to isn't working with different classes (and rails 4?) #17

Closed
fonji opened this issue Sep 27, 2013 · 1 comment
Closed

Linked_to isn't working with different classes (and rails 4?) #17

fonji opened this issue Sep 27, 2013 · 1 comment

Comments

@fonji
Copy link

fonji commented Sep 27, 2013

Hello!
First of all: this issue concerns the links branch. Please have a look at the corresponding issue #13 if you need more information.

An error is raised when I try to use linked_to objects using another class.

Some background first
I work in healthcare research. In the disorders classifications, a disorder has multiple children (to narrow the diagnosis) and multiple parents (multiple path may lead you to the same disorder). A disorder can also be found in multiple classifications (top-level disorders, you could say).
I created the models Disorder and Classification.
As we used SKOS:broader for the parents of a disorder, I created the links :broaders (= parents) and :narrowers (= children). There's also a :classifications link.
As nothing is too easy, I had to fork tripod to make it work in my environment which is Rails 4 (issue #14) and OpenRDF's Sesame (issue #15). I may have missed a part of code to patch.

Code
Here's (part of) my disorder model:

class Disorder
  include Tripod::Resource

  rdf_type RDF::SKOS.Concept # NB: this will change

  field # snip ...
  linked_to :broaders, RDF::SKOS.broader, class_name: 'Disorder', field_name: :broaders_uri, multivalued: true
  linked_from :narrowers, :broaders, class_name: 'Disorder', multivalued: true
  linked_to :classifications, RDF::SKOS.inScheme, class_name: 'Classification', multivalued: true
  # snip ...
end

And here is the Classification model:

class Classification
  include Tripod::Resource

  rdf_type RDF::SKOS.ConceptScheme

  field # snip...
  linked_from :narrowers, :broaders, class_name: 'Disorder', multivalued: true # a classification is also a top-level disorder
  linked_from :all_narrowers, :classifications, class_name: 'Disorder', multivalued: true
  #snip...
end

Now the problem
The broaders and narrowers of a disorder work great, thanks!
I can create a Classification instance so I'm sure that my model is loaded.
But as soon as I try to access the classifications of a disorder, I get this error:

undefined method `predicate' for nil:NilClass

The error occurs before I see any tripod log about loading the classifications data.
I'll comment as soon as I find my typo (still hoping it's one) or patched! Maybe classification[s] is a reserved keyword I didn't know.

Cheers,
Yannick

@fonji
Copy link
Author

fonji commented Sep 27, 2013

I was missing the latest commit, I merged just before Ric did it.
My bad. Sorry for your time.
My fork is updated with the correct code.
Everything is nice and beautiful in this world now.

@fonji fonji closed this as completed Sep 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant