0

by copying and trying to modify a scaffold manually in Rails 4, I got an error when I want to delete an article: uninitialized constant Article::Tag. Another error when I want to edit an Article: "undefined local variable or method `article_params'".

I don't know from where it can comes from, the highlited error which are displayed are @article.destroy and if @article.update(article_params). I don't understand at all considering I think having copied perfectely the scaffold...

def destroy
  @article.destroy
  respond_to do |format|
    format.html { redirect_to articles_url }
    format.json { head :no_content }
  end
end


def update
  respond_to do |format|
    if @article.update(article_params)
      format.html { redirect_to @article, notice: 'Article was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: 'edit' }
      format.json { render json: @article.errors, status: :unprocessable_entity }
    end
  end
end

Thansk you for your help

LHH
  • 3,233
  • 1
  • 20
  • 27
sidney
  • 2,704
  • 3
  • 28
  • 44
  • 2
    The problem is in your Article model, I believe – mikdiet Jan 11 '13 at 15:01
  • Thanks, It was the solution, I haven't think about the model at all! The destroy wasn't working because of the "has_and_belongs_to_many" And the editing problem wasn't working because of the "validates_presence_of" – sidney Jan 11 '13 at 15:08

0 Answers0