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

  • Home
  • SEARCH
  • 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 8837355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:42:10+00:00 2026-06-14T09:42:10+00:00

My app successfully creates rows for a table every time a user submits some

  • 0

My app successfully creates rows for a table every time a user submits some stats. Now I want to provide a delete button to be able to delete some rows.

When I click the delete button I get the error:

undefined method `destroy' for nil:NilClass

Seems like either rails doesn’t understand the destroy method in this case for whatever reason, or rails doesn’t see anything to destroy, hence the nil:NilClass.

My first question is in identifying which is the case, if either of those.

My second question is fixing it 😀

Here’s my show.html:

<% provide(:title, "Log" ) %>
<% provide(:heading, "Your Progress Log") %>

<div class="row">  
  <div class="span8">
    <% if @user.status_update.any? %>
      <h3>Status Updates (<%= @user.status_update.count %>)</h3>    
      <table>
        <thead>
          <tr>
            <th>Entry Date</th>
            <th>Weight</th>
            <th>BF %</th>
            <th>LBM</th>
            <th>Fat</th>
            <th>Weight Change</th>
            <th>BF % Change</th>
            <th>Fat Change</th>
          </tr>
        </thead>
      <tbody class = "status updates">
          <%= render @status_updates %>
      </tbody>        
    <% end %>
  </div>
</div>

The “<%= render @status_updates %>” calls the _status_update partial.

 <tr>
 .
 .
 .
 . 
 <% if current_user==(status_update.user) %> 
 <td>
       <%= link_to "delete", status_update, method: :delete %>

 </td>
 <%  end  %>         

</tr>                                    

And then finally, here is the StatusUpdateController

def destroy
    @status_update.destroy
    redirect_to root_url
end

Here are the parameters on the error page:

{"_method"=>"delete",
 "authenticity_token"=>"w9eYIUEd2taghvzlo7p3uw0vdOZIVsZ1zYIBxgfBymw=",
 "id"=>"106"}
  • 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-14T09:42:11+00:00Added an answer on June 14, 2026 at 9:42 am

    As you are not showing any code (filters or so) that could assign @status_update, I assume there is none. So, the instance variable @status_update in your in your destroy method is not set. You need to query the class with the object’s ID.

    Rewrite your destroy method as follows:

    def destroy
        @status_update = StatusUpdate.find(params[:id])
        if @status_update.present?
          @status_update.destroy
        end
        redirect_to root_url
    end
    

    Note: Replace the classname StatusUpdate with your actual class name.

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

Sidebar

Related Questions

I have implemented Single-Sign-On in my iOS 4.3 app successfully. Now I want to
I'm creating a simple back-end app through which the user can create/update/delete database rows
I have a rails app that creates a kml file and successfully loads it
Long time reader, first time poster here. I'm creating a test app that creates
In my Rails 3.2 app, I want to populate some fields based on calculations
I have successfully created an app that reads from a bundled .plist file and
I created a google app engine project. I just successfully mapped it to a
I have compiled a simple win32 app successfully with bc++ (2 lines excerpt only):
I've written an entire app pretty successfully in Django but I have this nagging
When i push Back button on Navigation controller app is successfully return to the

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.