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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:35:12+00:00 2026-06-06T02:35:12+00:00

Hi I need help with setting up the rails3-jquery-autocomplete gem with a manually assigned

  • 0

Hi I need help with setting up the rails3-jquery-autocomplete gem with a manually assigned foreign key in my database.

Here is what my models look like

 class User < ActiveRecord::Base
   has_many :reservations, :foreign_key => 'reserver_id'
   attr_accessible :login, :first_name, :last_name
 end

class Reservation < ActiveRecord::Base
  belongs_to :reserver, :class_name => 'User'
  attr_accessible :reserver, :reserver_id, :reserver_login
end

The users table in my database has all of the columns

The Reservations Controller has

autocomplete :users, :login

Routes.rb has

resources :reservations do
  get :autocomplete_users_login, :on => :collection
end

And in the reservations view I have this

      <%= f.autocomplete_field :reserver_id, autocomplete_users_login_reservations_path %>

Now when I try and test it I see that the calls are being made in my javascript console but I get the error 500. For example I tried searching for xno which is in a login column of my users database.

GET http://0.0.0.0:3000/reservations/autocomplete_users_login?term=xno 500 (Internal Server   Error) jquery.js:8241
  jQuery.ajaxTransport.send jquery.js:8241
  jQuery.extend.ajax jquery.js:7720
  jQuery.each.jQuery.(anonymous function) jquery.js:7246
  jQuery.extend.getJSON jquery.js:7263
  a.railsAutocomplete.fn.extend.init.a.autocomplete.source autocomplete-rails.js:17
  $.widget._search jquery-ui.js:6547
  $.widget.search jquery-ui.js:6540
  (anonymous function) jquery-ui.js:6335

Does this have anything to do with the fact that I am using foreign key in my database? If yes how should I structure my routing. I was following the gem documentation and tried to set it up so that I can look up the users table and list people by the login column of the users table, but so that the id gets returned and stored as :reserver_id once the user is selected. Previous code that worked with select field was

  <%= f.select :reserver_id, User.select_options, :prompt => true %>

where select_options method creates an array of login strings and id pairs in individual arrays.

I know that the solution is probably really easy, thank you for your help…

  • 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-06T02:35:15+00:00Added an answer on June 6, 2026 at 2:35 am

    My problem was silly but it turned out it had nothing to do with the fact that the category table used a custom foreign key. My first problem was using plural version of the table name rather than the singular. Once I changed all references to users to user I noticed that javascript console wasn’t throwing any exceptions at me so I figured that I had either broken everything and the call wasn’t being made or it was going through and it wasn’t rendering properly.

    The presence of proper MYSQL calls in the console confirmed my suspicion. That’s when I saw that the list was rendering way off to the right of my page probably due to strange styling happening somewhere else.

    Bottom line is having a custom foreign key doesn’t change usage of the gem at all. THe original table name should be used.

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

Sidebar

Related Questions

I need help with jQuery effects, after setting images to a position through style,
I need help setting up my MySQL Database. I would like the database to
I'm pretty new to database setup in Ruby and need help in setting it
I need a little help setting up a jquery event, basically when a user
I need help setting up a simple C++/C# SWIG project. I am having a
I need a little help setting up a HTTP Post in C#. I appreciate
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
I know this is not a programming question, and I need help with setting
I need a help with setting a random image using setImageResource method. In the
http://removed.com/jquery/test.html# I have three problems that I need help with. 1 ) When you

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.