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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:17:28+00:00 2026-06-07T15:17:28+00:00

so I have a tricky issue here I’m not sure how to solve. I

  • 0

so I have a tricky issue here I’m not sure how to solve.

  1. I have a Provider model that has_many :educational_affiliations
  2. EducationalAffiliation belongs_to :institution & belongs_to
    :provider

I have about 9000 universities in my database, so I’m using the handy-dandy rails3-jquery-autocomplete gem to give me type-ahead support. That’s all working great – on TOP of that I’m using cocoon to support the nesting of the :educational_affiliations form inside of the provider’s edit form.

So here’s where the issue comes — This works great for submitting new affiliation records, (I’m using some jquery to set the :institution_id on the :educational_affiliations_attributes object, works great)

BUT when I return to edit this later, of course the :institution_name isn’t populated, because it’s not part of the :educational_affiliations model, it’s in the :institution model.

Here’s what I just tried in my :educational_affiliations, which I assume is the right solution:

class EducationalAffiliation < ActiveRecord::Base
  attr_accessible :degree, :graduation_year, :honors, :institution_name, :institution_id, :provider_id
  belongs_to :institution
  belongs_to :provider

  # attr_accessor :institution_name

  validates :institution_id, :graduation_year, :provider_id, :degree, presence: true

  def institution_name
    Institution.find(institution_id).name
  end

end

(i had it working for saving using the attr_accessor, but I’ve commented it out for now)

So when I render the edit view with the above, I get a ActiveRecord::RecordNotFound: Couldn’t find Institution without an ID error — but when I open a debugger on that statement, the model DOES seem to know the institution_id…so confused why it doesn’t pick it up.

Am I just doing this in the worst way possible? I assume there’s a dumb solution.. 🙂

Here’s the partial that needs the name populated:

.nested-fields
  = f.input :institution_name, url: autocomplete_institution_name_data_path, as: :autocomplete, :input_html => {:id_element => '#provider_educational_affiliations_institution_id'}
  = f.input :institution_id, as: :hidden
  = f.input :provider_id, as: :hidden, input_html: { value: current_provider.id }
  = link_to_remove_association "Remove Degree", f
  • 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-07T15:17:32+00:00Added an answer on June 7, 2026 at 3:17 pm

    Instead of the virtual attribute method, try the following to define the attribute:

    delegate :name, :name=, :to => :institute, :prefix => true 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok so the issue here that I have a video camera which is connected
I have a simple issue, but the solution appears to be tricky. I want
I have a tricky problem that has had me scratching my head for a
I have sort of a tricky problem I'm attempting to solve. First of all,
I have what I think is a tricky question, but hopefully someone on here
I need to have custom checkboxes which wasn't that tricky. I made checkbox_selector to
I'm having a tough time figuring out a tricky issue. Here is what I
My first query where I got problem here : Tricky GROUP BY issue on
I am trying to build a website and have encountered a tricky issue with
Morning Guys, I have a CSS issue that's driving me up the wall. I

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.