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

  • SEARCH
  • Home
  • 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 8135635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:29:00+00:00 2026-06-06T10:29:00+00:00

I’ve rebuilt my network map and now I can’t seem to get my nested

  • 0

I’ve rebuilt my network map and now I can’t seem to get my nested model to work. It’s set up as IDF => Switch (each IDF has many switches). I’m trying to be able list the switches of the IDF, but I get the following error:

Mysql2::Error: Unknown column ‘switches.idf_id’ in ‘where clause’: SELECT switches.* FROM switches WHERE switches.idf_id = 1

I’m assuming that for some reason when the mysql table is built for the switches there is no column made to map it to a switch id. I have no idea why it isn’t. I’ve edited the models and re-rake the project a couple of times and I don’t know what’s missing. Any help would be much appreciated!

app/models/idf.rb:

class Idf < ActiveRecord::Base
  attr_accessible :location, :room_number
  has_many :switches
  accepts_nested_attributes_for :switches
end

app/models/switch.rb:

class Switch < ActiveRecord::Base
  attr_accessible :model, :title
  belongs_to :idf
end

app/views/idfs/show.html.erb:

<p id="notice"><%= notice %></p>

<p>
  <b>Location:</b>
  <%= @idf.location %>
</p>

<p>
  <b>Room number:</b>
  <%= @idf.room_number %>
</p>

<h2>Switches:</h2>
<%= render @idf.switches %>

<h2>Add a switch:</h2>
<%= render "switches/form" %>

<%= link_to 'Edit', edit_idf_path(@idf) %> |
<%= link_to 'Back', idfs_path %>

^^Everything worked fine until I tried to add the switch functionality.

  • 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-06-06T10:29:01+00:00Added an answer on June 6, 2026 at 10:29 am

    This sounds like an issue with your Switch database migration. Can you paste the migration?
    And are you generating migrations and models by hand, or using “rails generate …”?

    Your migration should look something like:

    class AddSwitch < ActiveRecord::Migration
    
      #assuming Rails 3
      def change
        create_table :switches do |t|
          # Add attributes
          t.references :idf  # same as t.integer :idf_id
        end
      end
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.