Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The action 'destroy' could not be found for SampleformsController

When I want to delete my data in database I got this error:

Unknown action
The action 'destroy' could not be found for SampleformsController

My controller destroy action code looks like this:

def destroy
  @sampleform = Sampleform.find_by_id(params[:id])

  if @sampleform.destroy
    redirect_to sampleforms_path
  end
end

again I got that same error

again I got that same error

like image 230
ganesan Avatar asked Dec 08 '25 10:12

ganesan


1 Answers

In your SampleformsController, you need to add a destroy method:

class SampleformsController < ApplicationController
  def destroy
    # destroy your record here
  end
end

You can find more information on this topic in the Ruby on Rails guides.

like image 61
fivedigit Avatar answered Dec 10 '25 02:12

fivedigit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!