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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:30:21+00:00 2026-06-15T10:30:21+00:00

I’m trying to implement a sortable list feature based off this example – http://railscasts.com/episodes/147-sortable-lists-revised

  • 0

I’m trying to implement a sortable list feature based off this example – http://railscasts.com/episodes/147-sortable-lists-revised .

The problem is that when I drop my element, i keep getting this error message:

Started POST "/applications/sort" for 127.0.0.1 at 2012-12-04 11:14:45 -0600
Processing by ApplicationsController#sort as */*
  Parameters: {"application_application_field_attributes_0"=>["id"], "application_application_field_attributes_1"=>["id"], "application_application_field_attributes_2"=>["id"]}
Completed 500 Internal Server Error in 1ms

NoMethodError (undefined method `each_with_index' for nil:NilClass):
  app/controllers/applications_controller.rb:91:in `sort'

views/applications/_form.html.erb

<%= form_for(@application, :class => "main") do |f| %>
...
<div class="sortable" data-update-url="<%= sort_applications_url %>">
    <%= f.fields_for :application_field do |fields| %>
        <%= render 'application_field_fields', f: fields %>  
    <% end %>
</div>
<% end %>

views/applications/_application_field_fields.html.erb

<div class="formRow" id="<%= f.object.position %>">
    <div class="grid2"><%= f.label :field_name %></div>
    <div class="grid3"><%= f.text_field :field_name %></div>
    <div class="grid2"><%= f.label :field_type %></div>
    <div class="grid3"><%= f.text_field :field_type %></div>
    <!-- Need to store the hidden field _destroy here so we can access it via jQuery -->
    <%= f.hidden_field :_destroy %>
    <div class="grid2" align="center"><%= link_to "Remove", '#', class: "remove_fields"%></div>
    <div class="clear"></div>
</div>

applications.js

$('.sortable').sortable({ 
    placeholder: "ui-state-highlight",
    forcePlaceholderSize: true,
    start: function(event, ui) {
        ui.item.addClass('dragging');
    },
    stop: function(event, ui) {
        ui.item.removeClass('dragging');
    },
    update: function(event, ui) {
        $.post($(this).data('update-url'), $(this).sortable('serialize'));
    }
});

controllers/applications#sort

# POST /applications/sort
  def sort
    puts '*********'
    puts '#####'
    puts 'params = ' #{params}
    puts '********'
    params[:application].each_with_index do |id, index| 
        Application.update_all({position: index+1}, {id: id})
    end
    render :nothing => true
  end

When i drop a sortable element, you can see that my params hash is empty. Why is that and how can i fix it?

EDIT

I’ll post my models so you can see the relationships

class Application < ActiveRecord::Base
    belongs_to :company
    has_many :application_field, :order => "position"
    accepts_nested_attributes_for :application_field, :allow_destroy => true
    attr_accessible :application_name, :application_field_attributes
end
class ApplicationField < ActiveRecord::Base
    belongs_to :application
    has_many :application_fields_value
    attr_accessible :field_name, :field_type, :field_value, :application_field_values_attributes
    accepts_nested_attributes_for :application_fields_value, :allow_destroy => true
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-06-15T10:30:22+00:00Added an answer on June 15, 2026 at 10:30 am

    I solved this by changing

    <div class="formRow" id="<%= f.object.position %>">
        <div class="grid2"><%= f.label :field_name %></div>
        <div class="grid3"><%= f.text_field :field_name %></div>
        <div class="grid2"><%= f.label :field_type %></div>
        <div class="grid3"><%= f.text_field :field_type %></div>
        <!-- Need to store the hidden field _destroy here so we can access it via jQuery -->
        <%= f.hidden_field :_destroy %>
        <div class="grid2" align="center"><%= link_to "Remove", '#', class: "remove_fields"%></div>
        <div class="clear"></div>
    </div>
    

    to

    <%= content_tag_for :div, f.object, :class => "formRow" do %>
        <div class="grid2"><%= f.label :field_name %></div>
        <div class="grid3"><%= f.text_field :field_name %></div>
        <div class="grid2"><%= f.label :field_type %></div>
        <div class="grid3"><%= f.text_field :field_type %></div>
        <!-- Need to store the hidden field _destroy here so we can access it via jQuery -->
        <%= f.hidden_field :_destroy %>
        <div class="grid2" align="center"><%= link_to "Remove", '#', class: "remove_fields"%></div>
        <div class="clear"></div>
    <% end %>
    

    Can someone explain why this works?

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

Sidebar

Related Questions

I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

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.