Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are getting a lot of concepts wrong here. Lemme explain what you are trying to do here. But before I do so I strongly suggest that you get a good Rails book and try out couple of the applications from those books before trying things on your own. Everybody starts at your level. Theres nothing wrong in what you are trying to do :). </p> <p>Firstly: Ruby code is executed only once when the page is loaded for the first time in the browser. You cannot use ruby in javascript. You can use Ruby to render javascript as you wish when you send the HTML page as a response to the request from the browser side not once after that. So the part where you are doing <code>var search = &lt;%User.paginate(page: params[:page]).search('$(this).val();')%&gt;</code> is impossible to do.</p> <p>You need to get these concepts right before developing. :) So get a good rails book. </p> <p>Alright.</p> <p>Secondly: I am assuming that your search works fine except for your keyup requirement. So Im guessing that you have your controllers and models in order. So let me explain AJAX to you.</p> <p>Remember when I said you can only execute ruby code or in other words invoke a Rails Controller only once when the page is loaded? Thats true but theres a magical thing called AJAX in the javascript world. This allows you to call the Rails Application and get responses without loading the page! This is exactly what you want here. You are trying to just update the search results. You dont wanna reload the entire page. You just want to update the results as the user presses keys on the search field. </p> <p>Using AJAX you can make a request to your server and get a response. So in your application, the request would be to the URL where the search form would submit if the user presses enter or submits. What would you pass as arguments to this URL? yes you guessed it right! the search field value. </p> <p>Alright after getting your concepts right start here: <a href="http://railscasts.com/episodes/240-search-sort-paginate-with-ajax?view=comments" rel="nofollow">http://railscasts.com/episodes/240-search-sort-paginate-with-ajax?view=comments</a></p> <p>Then you'll know what to do. </p> <p>Good luck.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload