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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:58:15+00:00 2026-06-12T09:58:15+00:00

I am using the rails3-jquery-autocomplete gem and it works neat when using it for

  • 0

I am using the rails3-jquery-autocomplete gem and it works neat when using it for fields that exist in the model. However, I have been trying to use it for associations and I fail to see how to make it work. So let’s explain what I have:

Models:

class Receipt < ActiveRecord::Base
  belongs_to :user
end

class User < ActiveRecord::Base
  has_many :receipts
end

Controller

class Admin::ReceiptsController < AdminController
 autocomplete :user, :name
  def index
    @receipts = Receipt.all
  end
  def show
    @receipt = Receipt.find_by_id(params[:id])
  end
  def edit
    @receipt = Receipt.find_by_id(params[:id])
    @users = User.all
  end
end

View (form):

<%= form_for(@receipt, :url => admin_receipt_path, :html => { :multipart => true }) do |f| %>
 <div class="clearfix">
  <%= f.label :value, "Value($)" %>
  <div class="input"><%= f.text_field :value %></div>
 </div>
 <div class="clearfix">
  <%= f.label :user_id, "User" %>
  <div class="input">
   <%= f.autocomplete_field :user_id, autocomplete_user_name_admin_receipts_path %>
  </div>
 </div>
.....

The thing is… I am able to fetch user names, but I want to actually store the user id in there. The same way I would like to show the name when the admin tries to edit an existing receipt with a user associated. Something that I am able to do with this drop down:

<div class="clearfix">
 <%= f.label :user_id, "User" %>
 <div class="input"><%= f.select :user_id, @users.collect {|p| [ p.name, p.id ] },{:prompt => 'Select a User'} %></div>
</div>

I am failing to see how would I do this with this gem….

  • 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-12T09:58:16+00:00Added an answer on June 12, 2026 at 9:58 am

    Ryan Bates did a screencast on this. Clean and well explained

    Screencast

    If you don’t feel like subscribing try torrent

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

Sidebar

Related Questions

I'm using 'rails3-jquery-autocomplete' gem, but it doesn't have multi column search, but there is
Recently I started using https://github.com/crowdint/rails3-jquery-autocomplete It works great, but I was trying to set
I'm using auto_complete plugin: https://github.com/crowdint/rails3-jquery-autocomplete I have installed the gem and added require line
Is it possible to select DISTINCT values using Rails3 JQuery autocomplete gem?
I'm using the rails3-jquery-autocomplete gem to autocomplete the name of a user, search attribute
I am using the rails3-jquery-autocomplete gem to autocomplete the a field (product) in a
In Rails, I'm using rails3-jquery-autocomplete gem to autocomplete the username owner on a photos#edit
Possible Duplicate: error saying “autocomplete method doesn't exist” with rails3-autocomplete gem I am trying
I have such problem: I'm using rails, devise gem and jQuery validation plugin. I
I have started using jQuery and rails. I have made a simple form that

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.