Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Fixes a bug in the name... not sure if this breaks something elsewhere! #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maxsum-corin
Copy link
Contributor

Hi,

I was trying to add a relationship on a session to a user. i.e.

#app/model/session.rb
require 'dm-rails/session_store'
class Session < Rails::DataMapper::SessionStore::Session
  belongs_to :user, :required => false
end

#config\initializers\session_store.rb
require 'dm-rails/session_store'
Rails::DataMapper::SessionStore.session_class = Session
My::Application.config.session_store Rails::DataMapper::SessionStore

But I kept hitting this error: Cannot find the parent_model User for session in user

This patch fixes my problem. I'm not sure if this has any unintended side-effects... not sure why self.name is overwritten in the first place. Case matters when DataMapper::Ext::Module.find_const comes to find the Model class for the belongs_to relationship; not sure if any other code relies on lower case.

Please let me know if I'm going about this the wrong way.

Cheers,
Corin

@tpitale
Copy link
Member

tpitale commented Feb 14, 2016

I'll take a look, thanks @maxsum-corin.

@tpitale tpitale added this to the 1.3.0 milestone Feb 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants