Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby on Rails sortable list
    primarykey
    data
    text
    <p>I created a sortable list in my RoR project, unfortunately it's not saving the list position. Upon page refresh the items return to their normal spot. I've pasted the code below or you can git it: git://github.com/mdgrech/23notes-.git</p> <pre><code>app/views/notes/index.html.erb ///////////////////////////////////////////////////////////////////////////////////////////// &lt;div id="newNoteDiv"&gt;&lt;/div&gt; &lt;ul id="notesList"&gt; &lt;% for note in @notes %&gt; &lt;li id="&lt;%=h note.position %&gt;"&gt; &lt;span class="handle"&gt;[drag]&lt;/span&gt; &lt;div id="listContent"&gt; &lt;h3&gt;&lt;%= link_to note.title, edit_note_path(note) %&gt;&lt;/h3&gt; &lt;p&gt;&lt;%=h note.content %&gt;&lt;/p&gt; &lt;%= link_to "Destroy", note, :confirm =&gt; 'Are you sure?', :method =&gt; :delete %&gt; &lt;/div&gt; &lt;/li&gt; &lt;% end %&gt; &lt;/ul&gt; &lt;%= sortable_element("notesList", :url =&gt; sort_notes_path, :handle =&gt; "handle" ) %&gt; app/controllers/notes_controller.rb ////////////////////////////////////////////////////////////////////////////////////////// def index @notes = Note.all(:order =&gt; "position") end def sort params[:notes].each_with_index do |id, index| Note.update_all(['position=?', index+1], ['id=?', id]) end render :nothing =&gt; true end config/routes.rb ////////////////////////////////////////////////////////////////////////////////////////// map.resources :notes, :collection =&gt; { :sort =&gt; :post } map.root :notes app/models/note.rb ////////////////////////////////////////////////////////////////////////////////////////// class Note &lt; ActiveRecord::Base acts_as_list end </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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