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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:27:34+00:00 2026-05-26T10:27:34+00:00

I followed Ryan Bates’ rails tutorial on setting up a sortable list of objects.

  • 0

I followed Ryan Bates’ rails tutorial on setting up a sortable list of objects. With some modifications, it’s now working to the point where I can drag and drop a list of "belongs to" elements on a ‘has many’ page, and the post action is sent to my controller… Which then gives a 500 error

NoMethodError (You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each_with_index):
app/controllers/cuttings_controller.rb:87:in `sort’

I believe this is because while Ryan’s controller knew which cutting it’s dealing with, mine needs the parameters passed to it.

Here is the line on my users page (which holds ‘cuttings’):

<%= sortable_element('faqs', :url => 'sort_cutting', :handle => "handle") %>

And here is the definition in the cuttings controller:

  def sort
    params[:cuttings].each_with_index do |id, index|
      Cutting.update_all(['position=?', index+1], ['id=?', id])
    end
    render :nothing => true
  end

Would somebody be kind enough to tell me how to tweak this so it will work properly? Which parameters should I pass? I’ve tried :cutting => @cutting.id, which didn’t work. The post route is set up using:

match 'users/sort_cutting' => 'cuttings#sort'

… Which is a bit ugly, but the only way I could get it to work!

Thanks in advance.

  • 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-26T10:27:35+00:00Added an answer on May 26, 2026 at 10:27 am

    I answered this by reading this post – the params didn’t match ‘faqs’, the sortable element I was trying to deal with. Simple when you know how!

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

Sidebar

Related Questions

I have successfully followed Ryan Bates tutorial of paperclip and have it working correctly.
I followed this tutorial on configuring the Rails plugin ExceptionNotifier. I know that I
I followed this tutorial for setting Autlogic up properly . So, my site needs
I followed Ryan Bates Omniauth Part1 railscats http://railscasts.com/episodes/235-omniauth-part-1 . I put twitter and Facebook
I followed a tutorial on reusing tabs inside Firefox, and right now my extension
I followed a tutorial for sending email in Rails, and I have this in
I'd followed the railscast 213 (calendars) from Ryan Bates Where he makes use of
I am new to rails and i need some help working with calendar I
I've followed Ryan Fait's sticky footer example and for some reason my footer, while
I have followed a screen cast form ryan bates railscast and every thing is

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.