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

About the has_one association problem #120

Closed
kai209209 opened this issue Mar 12, 2014 · 3 comments
Closed

About the has_one association problem #120

kai209209 opened this issue Mar 12, 2014 · 3 comments

Comments

@kai209209
Copy link

catch

My Gemfile file use
gem 'paranoia', :github => 'radar/paranoia', :branch => 'rails4'

User model
has_one :organization, dependent: :destroy
has_many :activities, dependent: :destroy

Organization model
belongs_to :user

Activity model
belongs_to :user

The user has_one organization , and user has_many activities.
Once I restore the user record, execute "User.restore(10, :recursive => true)", all activities are ok, but the organization still missing.
Look at the picture, the query :
SELECT organizations.* FROM organizations WHERE organizations.deleted_at IS NULL AND organizations.user_id = 10 ORDER BY organizations.id ASC LIMIT 1

Why it found the record : 'deleted_at' IS NULL
The correct should be "'deleted_at' IS NOT NULL " ,right?
So, is it a bug?

@kai209209
Copy link
Author

my rails version is '4.0.2'

@radar
Copy link
Collaborator

radar commented Mar 12, 2014

@kai209209 I don't think that it'll fix this particular issue, but you should really upgrade to 4.0.3, since that's the latest release and contains security problems.

@radar
Copy link
Collaborator

radar commented Sep 16, 2014

I believe #123 fixes this problem.

@radar radar closed this as completed Sep 16, 2014
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

2 participants