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 8794733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:17:30+00:00 2026-06-13T23:17:30+00:00

I cant find out where is an error with this relation: class Education <

  • 0

I cant find out where is an error with this relation:

class Education < ActiveRecord::Base
  attr_accessible :description, :graduation, :student_id, :faculty_id, :department_id

  has_one :faculty
  belongs_to :student
end
#  id          :integer          not null, primary key
#  student_id  :integer
#  faculty_id  :integer
#  description :text
#  graduation  :string(255)

class Faculty < ActiveRecord::Base
  attr_accessible :department_id, :name

  belongs_to :education
  belongs_to :department
end

# == Schema Information
#
# Table name: faculties
#
#  id            :integer          not null, primary key
#  name          :string(255)
#  department_id :integer

Why I have to add education_id to faculties table?
Each Education has only one faculty and faculty belongs to many educations.

>> Education.last.faculty
  Education Load (0.3ms)  SELECT "educations".* FROM "educations" ORDER BY "educations"."id" DESC LIMIT 1
  Faculty Load (0.2ms)  SELECT "faculties".* FROM "faculties" WHERE "faculties"."education_id" = 1 LIMIT 1
SQLite3::SQLException: no such column: faculties.education_id: SELECT  "faculties".* FROM "faculties"  WHERE "faculties"."education_id" = 1 LIMIT 1
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: faculties.education_id: SELECT  "faculties".* FROM "faculties"  WHERE "faculties"."education_id" = 1 LIMIT 1
from /Users/rege/.rvm/gems/ruby-1.9.3-p194@ckdatabase/gems/sqlite3-1.3.6/lib/sqlite3/database.rb:91:in `initialize'
  • 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-13T23:17:31+00:00Added an answer on June 13, 2026 at 11:17 pm

    Whichever side you put a ‘belongs_to’ in will invariably have an id of the associated objects – it’s kind of by definition. If you belong_to something you don’t also belong_to another instance.

    If you want each Education to have only one Faculty, there are two alternatives:

    • use a one-to-one: when you also want the Faculty to only have one Education
    • use a belongs_to with a one-to-many: when you want each Faculty to have multiple Educations

    So you might try this instead:

    class Education < ActiveRecord::Base
      attr_accessible :description, :graduation, :student_id, :faculty_id, :department_id
    
      belongs_to :faculty
      belongs_to :student
    end
    
    class Faculty < ActiveRecord::Base
      attr_accessible :department_id, :name
    
      has_many :education
      belongs_to :department
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting this error on the following code, and cant figure out why.
every thing seems right but cant find out the reason for error.. i followed
I cant seem to find out how to get my ListView (OnListItemClick), to open
I can't find out why throw this expression always a NullPointerException: String jpql =
Hi i got stuck with this problem, i can't find out how to get
This should be easy to find out but I can't seem to find it
I cant seem to figure out a way catch ActiveRecord Exceptions using METHOD:2 METHOD:1
I cant find out how to use the WKT format in OpenLayers. I have
I cant figure out what is wrong with the following code: class ArticlesController extends
Ive been going over this for a couple days and i just cant find

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.