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

RuntimeError when saveing HABTM #760

Closed
jcoyne opened this issue Apr 7, 2015 · 0 comments
Closed

RuntimeError when saveing HABTM #760

jcoyne opened this issue Apr 7, 2015 · 0 comments

Comments

@jcoyne
Copy link
Member

jcoyne commented Apr 7, 2015

class TimeSpan < ActiveFedora::Base
  has_many :images, inverse_of: :created # predicate: ::RDF::DC.created
end
class Image < ActiveFedora::Base
   has_and_belongs_to_many :created, predicate: RDF::DC.created, class_name: 'TimeSpan'
end

Image.new(created: [TimeSpan.new])

causes:

RuntimeError: Unable to lookup the :predicate attribute for has_many :images on TimeSpan because Image specifies "class_name: 'ActiveFedora::Base'".  Either specify a specific class_name in Image or set :predicate in the has_many declaration on TimeSpan
    from /Users/justin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/bundler/gems/active_fedora-14566e3e435a/lib/active_fedora/associations/collection_association.rb:358:in `find_reflection_for_relation'

it does work if you set the predicate on has_many, but it seems that there's enough information here to not require that.

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