I’m new to rails, ruby, and web development in general, and I’m having trouble trying to remove an object from my database.
I get “1 error prohibited this debate from being saved: Proposition can’t be blank”
when I call the destroy method of the object.
This is my link:
<%= link_to 'Delete this debate', debates_path, :method => :delete %>
and this is my destroy method:
def destroy
Debate.find(params[:id]).destroy
respond_to do |format|
format.html { redirect_to(debates_path) }
format.xml { head :ok }
end
end
If the debate is being destroyed anyway, why do I still get an error when the proposition is blank?
Edit:
The model for the debate:
class Debate < ActiveRecord::Base
validates :proposition, :presence => true
has_many :responses, :dependent => :destroy
end
I’m following the tutorial from here: http://guides.rubyonrails.org/getting_started.html
Or just: