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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:25:53+00:00 2026-06-03T15:25:53+00:00

Background: I’ve been doing RoR for about a year now, and am fairly comfortable

  • 0

Background: I’ve been doing RoR for about a year now, and am fairly comfortable with it, however, I know next to nothing about Javascript.

I’ve been playing around with some jquery autocomplete stuff in my rails app. I pretty much had a version working, but needed some tokenized fields too for a one to many relationship.

Right on cue – good old Ryan Bates does a railscast on it. So I start following the instructions.

Got a little bit nervous when I had to start installing ‘jquery-rails’ gem (I’d already installed jrails to get the other stuff working).

As suspected, it broke some stuff but I managed to get that working again.

Anyway, I got most of the way through the tutorial, and everything was going fine – I’ve got the tokenizer script to find the correct input field and it acts as expected. I’ve tested the json link too – that sends back all the right stuff.

However when I start typing in the text field – nothing happens, and when I view the console window it comes back with:

Uncaught TypeError: Cannot call method 'replace' of undefined
  jQuery.jQuery.extend._Deferred.deferred.resolveWith
  done
  jQuery.ajaxTransport.send.callback

I can make guesses as to why this is going wrong – but any expert advice would be greatly appreciated.

(I should also add – I’m using formtastic too)

Thanks in advance.

  • 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-03T15:25:54+00:00Added an answer on June 3, 2026 at 3:25 pm

    Ok, finally figured it out.

    It turns out that my author’s name column is not name but rather author. So I needed to make a change inside the js.coffee script to override that default search of name.

    The line you need to use is:

    propertyToSearch: "author"
    

    My whole book.js.coffee file now looks like this:

    jQuery ->
      $('#book_author_tokens').tokenInput '/authors.json'
        theme: 'mac'
        prePopulate: $('#book_author_tokens').data('load')
        propertyToSearch: "author"
    

    This actually fixed the error Uncaught TypeError: Cannot call method 'replace' of undefined

    Of course, if you do use a different column name you will want to also edit the functions in the author.rb file to reflect that:

    def self.tokens(query)
          authors = where("author like ?", "%#{query}%")
          if authors.empty?
            [{id: "<<<#{query}>>>", author: "New: \"#{query}\""}]
          else
            authors
          end
        end
    
        def self.ids_from_tokens(tokens)
          tokens.gsub!(/<<<(.+?)>>>/) { create!(author: $1).id }
          tokens.split(',')
        end
    

    Edit

    Another thing I had to do for the fieldsto be prepopulated with the existing authors was change this:

    = f.input :author_tokens, :data => { :load => @book.author }
    

    To this:

    = f.input :author_tokens, :input_html => { :data => { :load => @book.author } }
    

    And then they would show up.

    Hope this helps you.

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

Sidebar

Related Questions

Background: Over the next month, I'll be giving three talks about or at least
Background: I'm writing a 'standard' (nothing special) web application in Ruby (not Rails) and
Background I have a ror application which is continuously recording and showing on a
I am reading a book about Javascript and jQuery and using one of the
Background I've recently been a part of a project where twisted was used. We
Background I have been asked by a client to create a picture of the
Background & Objective: I have a UISplitViewController based iPad app - till now it
Background: I am a beginner javascript developer who is trying to understand and learn
Background : I'm trying to convert some JavaScript code which uses the the Crossfilter
Background I admit, this question stems from an ultimate lack of deep understanding of

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.