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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:01:37+00:00 2026-05-28T20:01:37+00:00

I’m getting the below error when using jquery ui slider while update via ajax:

  • 0

I’m getting the below error when using jquery ui slider while update via ajax:

ActionView::Template::Error (undefined method `model_name' for Fixnum:Class):
1: $("#x_stock_list").html("<%= escape_javascript(render(@date_range)) %>");
app/views/home/index.js.erb:1:in`_app_views_home_index_js_erb__1074827181885368454_2504361900'

My jquery slider function looks like this:

<script type="text/javascript">
$(function() {
    $( "#x_slider" ).slider({
    range: true,
    step: 1,
    min: 1,
    max: 52,
    values: [1, 52 ],
    stop: function(event, ui) {
       var url_param = $('#x_slider').slider('option', 'values');
       $('#x_low_selected').html(ui.value);      
       $.ajax({
         type: "GET",
         data: ({ weeks: url_param[0] }),
         url: $(this).attr('data-href'),
         dataType: 'script'
       });
     }
   });
 });
</script>

In my home controller, I have this:

 def index
    unless params[:weeks]
      @date_range = 4
    else
      @date_range = Home.filter(params[:weeks])
    end
  end

And in my model:

  def self.filter(weeks)
    timeago = weeks.to_i
  end 

Finally, in my index.js

 $("#x_stock_list").html("<%= escape_javascript(render(@date_range)) %>");

When I drag the slider, the value is displayed fine:

 Parameters: {"weeks"=>"8", "_"=>"1327514933685"}

However it throws that error.

If I manually navigate the url http://localhost:3000/?weeks=9 everything works fine.

Can someone explain what I’m doing wrong here please?

  • 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-28T20:01:38+00:00Added an answer on May 28, 2026 at 8:01 pm

    The render method is not necessary here it’s purpose is to render partials, files or text. You are passing the number 4.

    You don’t need to escape_javascript for a number either as it expects a class that responds to gsub.

    #From the above link:    
    result = javascript.gsub(%r(\\|<\/|\r\n|\3342\2200\2250|[\n\r"'])/) {|match| JS_ESCAPE_MAP[match] }
    javascript.html_safe? ? result.html_safe : result
    

    Either use:

    $("#x_stock_list").html("<%= @date_range %>");
    

    Or convert it to a string:

    $("#x_stock_list").html("<%= @date_range.to_s %>");
    

    For highcharts in the past, I have done something along the lines of:

    $.getJSON('traffic_sources.json', null, function(data) {
        pie_chart("traffic_sources_graph", data.traffic_sources);
    });
    
    function pie_chart(div, data)
    {
       new Highcharts.Chart({
          chart: {
             renderTo: div,
             backgroundColor: '#dddddd'
          },
           series: [{
             type: 'pie',
             name: 'Browser share',
             data: data
          }]
       });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.