Note that there are some explanatory texts on larger screens.

plurals
  1. POForm submitting using jquery without ajax in rails
    primarykey
    data
    text
    <p>I am new to rails.i Want to sort content using jquery by selecting value from dropdown list. so i am having problem to submit a form to a specific controller action using jquery. I have a category model which has many products.In my category show i have a form like bellow:</p> <pre><code> &lt;%= form_for(:category, :url =&gt; sort_category_path, method: 'GET', :class=&gt; " form-inline pull-left") do |f| %&gt; Sort By : &lt;select id ="sort" name= "order_by"&gt; &lt;option&gt;Default&lt;/option&gt; &lt;option&gt;Name&lt;/option&gt; &lt;option&gt;Pirce&lt;/option&gt; &lt;/select&gt; &lt;%end%&gt; </code></pre> <p>here at this form i am not sure what does mean by :category ? Jquery for submit the form : </p> <pre><code> $('select#sort').change( function(e){ $(this).closest('form').trigger('submit'); }); </code></pre> <p>Then at my category controller i have a sort_item action like this:</p> <pre><code> def sort_item @category_sort = Category.find(params[:id]) @products = @category_sort.products.order("#{params[:order_by].to_s} ASC") end </code></pre> <p>i dont know how to send response to the request. the server log says :</p> <p>Started GET "/en/categories/tshart/sort_item?utf8=%E2%9C%93&amp;order_by=Pirce" for 127.0.0.1 at 2013-11-11 12:53:49 +0600 Processing by CategoriesController#sort_item as HTML Parameters: {"utf8"=>"✓", "order_by"=>"Pirce", "locale"=>"en", "id"=>"tshart"} Category Load (0.3ms) SELECT <code>categories</code>.* FROM <code>categories</code> WHERE <code>categories</code>.<code>slug</code> = 'tshart' LIMIT 1</p> <p>Redirected to <a href="http://test.com/en/categories/tshart" rel="nofollow">http://test.com/en/categories/tshart</a> Filter chain halted as :find_category rendered or redirected Completed 301 Moved Permanently in 6.7ms (ActiveRecord: 0.3ms)</p> <p>keep in mind that test.com stands for localhost:3000 .</p> <p>i want to know what i am doing wrong here ,why the sorting is not working or is there any better way to accomplish my sorting task?</p> <p>please help me . thanks in advance.</p>
    singulars
    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. This table or related slice is empty.
    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