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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:21:06+00:00 2026-05-22T02:21:06+00:00

I am working in rails2.3.11. I have a javascript like <script type=text/javascript> $(item).autoSuggest(/users/sampledata,{selectedItemProp: name,

  • 0

I am working in rails2.3.11.
I have a javascript like

 <script type="text/javascript">
        $(item).autoSuggest("/users/sampledata",{selectedItemProp: "name", searchObjProps: "name,login", asHtmlID: elmid,beforeRetrieve: function(string){ $('#spinner').show(); return string; },retrieveComplete: function(data){ $('#spinner').hide(); return data; } });
 </script>

I am trying to convert the path “/users/sampledata” to rails format like sampledata_users_path.. how to do this ??

The controller is Users controller and action is sampledata this action has

   def sampledata
@users = User.search(params["q"].gsub(/[^ \w]/, "").strip + "*", :limit => 8)
js = []
@users.each do |user|
      js << {:value => user.id.to_s, :name => user.name, :image => user.avatar.url(:micro), :login => user.login}
end
respond_to do |format|
  format.json { render :json => js.to_json }
end
     end
  • 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-05-22T02:21:07+00:00Added an answer on May 22, 2026 at 2:21 am

    Is the above “javascript” in a javascript file or is it a part of your erb template?

    If its a part of your erb template then its easy.

    <script type="text/javascript">
      $(item).autoSuggest("<%= sampledata_users_path %>",{selectedItemProp: "name", searchObjProps: "name,login", asHtmlID: elmid,beforeRetrieve: function(string){ $('#spinner').show(); return string; },retrieveComplete: function(data){ $('#spinner').hide(); return data; } });
     </script>
    

    If the above is not in a dynamically generated file, you may want to look at a plugin which reads the routes file and generates javascripts constants for use in js. I think it was called “less_routes” or something.

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

Sidebar

Related Questions

I am currently working on rails3 application that uses jQuery. I have a javascript
I have my Ajax working, builtin Rails javascript, with the submit button. However, I
I have a site that uses the Facebook JavaScript API to allow users to
I am working on a rails application (I have some experience with rails). But,
I'm working on a Rails application where I have some a set of two
I am thinking of working on a Rails application that uses PostgreSQL. I have
Hi Currently i am working on a rails project . where i have to
Background Currently, I am working on a Rails application. I have different products that
I have a fantasy football league rails app that was working last year and
I'm working with an older version of Rails and ActiveRecord that does not have

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.