Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6193267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:05:20+00:00 2026-05-24T03:05:20+00:00

Given this model in legacy code, with RoR 2.3.11: class Assignment < ActiveRecord::Base belongs_to

  • 0

Given this model in legacy code, with RoR 2.3.11:

class Assignment < ActiveRecord::Base
  belongs_to :source_person 
  belongs_to :destination_person
  belongs_to :laptop

  def self.setScope(places_ids)
    find_include = [:laptop => {:owner => {:performs => {:place => :ancestor_dependencies}}}]
    find_conditions = ["place_dependencies.ancestor_id = (?)", places_ids]

    scope = { :find => { :conditions => find_conditions, :include => find_include } }
    Assignment.with_scope(scope) do
      yield
    end
  end
end

Whenever it reaches the Assignment.with_scope statement, I get the following exception:

 Assignment Delete all (0.0ms)   Mysql::Error: Unknown column 'place_dependencies.ancestor_id' in 'where clause': DELETE FROM `assignments` WHERE (`id` IN (17)) AND (place_dependencies.ancestor_id = (1)) 

My schema looks like this:

  create_table "assignments", :force => true do |t|
    t.date    "created_at"
    t.date    "date_assigned"
    t.time    "time_assigned"
    t.integer "source_person_id"
    t.integer "destination_person_id"
    t.integer "laptop_id"
    t.text    "comment"
  end

  add_index "assignments", ["destination_person_id"], :name => "assignments_destination_person_id_fk"
  add_index "assignments", ["laptop_id"], :name => "assignments_laptop_id_fk"
  add_index "assignments", ["source_person_id"], :name => "assignments_source_person_id_fk

  create_table "place_dependencies", :force => true do |t|
    t.integer "descendant_id"
    t.integer "ancestor_id"
  end

  add_index "place_dependencies", ["ancestor_id"], :name => "place_dependencies_ancestor_id_fk"
  add_index "place_dependencies", ["descendant_id"], :name => "place_dependencies_descendant_id_fk"

I have almost the same code across multiple models, but everything works fine there. Could you give me a hint, on how to tackle this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:05:21+00:00Added an answer on May 24, 2026 at 3:05 am

    After doing the following it works:

     def self.setScope(places_ids)
        find_include = {
          :laptop => {
            :owner => {
              :performs => {
                :place => :ancestor_dependencies}
            }
          }
        }
        find_conditions = {"place_dependencies.ancestor_id" => places_ids}
    
        Assignment.all :joins => find_include, :conditions => find_conditions
        yield
      end
    

    This answer needs review from a more experienced Ruby on Rails developer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is just an example, but given the following model: class Foo(models.model): bar =
Given this example: abstract class Base { type Value } case object Foo extends
Given this code: public class Car { public virtual int CarId { get; set;
Given this entity model variable: DataBaseEntities db = new DataBaseEntities (); The below code
Given this very familiar model of prototypal construction: function Rectangle(w,h) { this.width = w;
Given this class class Foo { // Want to find _bar with reflection [SomeAttribute]
Given this example: <img class=a /> <img /> <img class=a /> <img class=a id=active
I have built a base class for my view model(s). Here is some of
Given this really simple Wicket component: public class ProductImage extends WebComponent { public ProductImage(String
Suppose I have this model: public class ViewModel { [Required] public string UserInput {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.