Questions tagged [dependent-destroy]

27 questions
0
votes
1 answer

How to destroy a dependent if it is aliased?

class Team < ApplicationRecord end class Game < ApplicationRecord belongs_to :winner, class_name: 'Team' belongs_to :loser, class_name: 'Team' end Thanks in advance. Is it possible to write a dependence for destroy a belonged Game instance…
AlekS
  • 3
  • 1
0
votes
2 answers

rails dependent destroy looking for non existing table

I am getting error: PG::UndefinedTable: ERROR: relation "profiles_rsl_codes" does not exist LINE 5: when I try to destroy a profile. I have a table called rsl_codes_profiles and in my profile model I have has_many :rsl_codes_profiles,…
ryan2johnson9
  • 724
  • 6
  • 21
0
votes
1 answer

how to do ruby on rails relationship dependent destroy

http://guides.rubyonrails.org/association_basics.html Based on the above example, I created: class Physician < ActiveRecord::Base has_many :appointments has_many :patients, through: :appointments end class Appointment < ActiveRecord::Base …
Axil
  • 3,606
  • 10
  • 62
  • 136
0
votes
1 answer

Rails model namespacing dependent destroy causes mysql error unknown field

I have several models in a separate folder called jira (instance.rb, generic_field.rb, etc.). They are are all namespaced under JIRA, for example JIRA::Instance < ActiveRecord::Base, JIRA::GenericField < ActiveRecord::Base. Here are the two…
Dan F.
  • 345
  • 1
  • 3
  • 12
0
votes
1 answer

Neo4j gem - dependent: :destroy not destroying

Problem: dependent destroy ain't happening with this setup! Help me spot the problem! The event has questions, and each question can have many answers event.rb include Neo4j::ActiveNode has_many :both, :users, model_class: 'User', rel_class:…
Clam
  • 935
  • 1
  • 12
  • 24
0
votes
1 answer

default destroy to a sidekiq task

In my Rails app, I have a model called Steps that can have many images: class Step < ActiveRecord::Base has_many :images, :dependent => :destroy ... Because of the dependent destroy condition, when I delete a step, it deletes all…
scientiffic
  • 9,045
  • 18
  • 76
  • 149
0
votes
1 answer

Circular dependent: :destroy in ActiveRecord possible?

Is it safe to have circular dependent: :destroy options in ActiveRecord models? class Student < ActiveRecord::Base has_one :user, dependent: :destroy end class User < ActiveRecord::Base belongs_to :student, dependent: :destroy end If I delete a…
0
votes
3 answers

has_one, dependent: destroy not working

I am using Devise for my user authentication and would like to destroy an associated profile along with the user. My failing spec looks like this: it "should destroy associated profile" do profile = @user.profile @user.destroy …
mpgarate
  • 535
  • 5
  • 12
0
votes
1 answer

Rails dependent destroy error

I have a Rails Movie app. With, obviously, a movie table. A movie has_many :comments, :dependent => :destroy and a comment belongs_to :movie. A comment also belongs_to :user so when a new User comments on a movie, that comment will display on their…
0
votes
1 answer

App crashing on heroku with :dependent => :destroy_all

Note everything works in local enviromnment This is the code PublicActivity::ORM::ActiveRecord::Activity.class_eval do attr_accessible :reference_type, :reference_id has_many :notifications, :dependent => :destroy_all has_many :users, :through =>…
Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
0
votes
1 answer

Nested Resource Not Properly Destroyed on Dependent Destroy

I'm having issue with a youtube video being destroyed properly in a nested belongs_to has_one relationship between a sermon and its sermon video when using :dependent => :destroy. I'm using the youtube_it gem and have a fairly vanilla setup. The…
0
votes
2 answers

How can I trigger :dependent=> destroy

I have two models, User and Image. class User < ActiveRecord::Base has_many :images,:order => "created_at DESC", :dependent => :destroy, :conditions => "archive = 0" def destroy self.archive = 1 self.deleted_at = Time.now self.save …
Mohit Jain
  • 43,139
  • 57
  • 169
  • 274
1
2