title: Undefined method for model in Ruby on Rails in Comment-Article application
body: <p>I am doing basic ruby on rails app and am encountering strange error while am trying to save comment (model Comment) in my article (model Article). Namely i get the error &quot;undefined method title for #Comment:0x000001ce6c353108, i have checked numerous times on stackoverflow and other places but couldn't find the solution.
  I can save the articles, but cannot save the Comment which belongs to particular Article, and the error is in the statement <code>@comment = @article.comments.create(comment_params)</code> which should i think take particular found article and save it, method on @article.comments is used to create and save the comment.
  I don't have title anywhere in comment model.</p>
  <p>My commentsController looks like this:</p>
  <pre><code>class CommentsController &lt; ApplicationController
    def create
      @article = Article.find(params[:article_id])
      @comment = @article.comments.create(comment_params)
      redirect_to article_path(@article)
    end
  
  
      def comment_params
        params.require(:comment).permit(:commenter, :body)
      end
  
  end
  </code></pre>
  <p>and show.html looks like below:</p>
  <pre><code>&lt;h1&gt;&lt;%= @article.title %&gt;&lt;/h1&gt;
  
  &lt;p&gt;&lt;%= @article.body %&gt;&lt;/p&gt;
  
  &lt;ul&gt;
    &lt;li&gt;&lt;%= link_to &quot;Edit&quot;, edit_article_path(@article) %&gt;&lt;/li&gt;
  
  
   &lt;li&gt;&lt;%= link_to &quot;Delete&quot;, article_path(@article),
                    method: :delete,
                    data: { confirm: &quot;Are you sure?&quot; } 
        %&gt;&lt;/li&gt;
  
  &lt;/ul&gt;
  
  
  &lt;h2&gt;Comments&lt;/h2&gt;
  &lt;% @article.comments.each do |comment| %&gt;
    &lt;p&gt;
      &lt;strong&gt;Commenter:&lt;/strong&gt;
      &lt;%= comment.commenter %&gt;
    &lt;/p&gt;
  
    &lt;p&gt;
      &lt;strong&gt;Comment:&lt;/strong&gt;
      &lt;%= comment.body %&gt;
    &lt;/p&gt;
  &lt;% end %&gt;
  
  
  &lt;h2&gt;Add a comment:&lt;/h2&gt;
  &lt;%= form_with model: [ @article, @article.comments.build ] do |form| %&gt;
    &lt;p&gt;
      &lt;%= form.label :commenter %&gt;&lt;br&gt;
      &lt;%= form.text_field :commenter %&gt;
    &lt;/p&gt;
    &lt;p&gt;
      &lt;%= form.label :body %&gt;&lt;br&gt;
      &lt;%= form.text_area :body %&gt;
    &lt;/p&gt;
    &lt;p&gt;
      &lt;%= form.submit %&gt;
    &lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>
  <p>My _form.html looks like:</p>
  <pre><code>&lt;%= form_with model: article do |form| %&gt;
    &lt;div&gt;
      &lt;%= form.label :title %&gt;&lt;br&gt;
      &lt;%= form.text_field :title %&gt;
      &lt;% article.errors.full_messages_for(:title).each do |message| %&gt;
        &lt;div&gt;&lt;%= message %&gt;&lt;/div&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  
    &lt;div&gt;
      &lt;%= form.label :body %&gt;&lt;br&gt;
      &lt;%= form.text_area :body %&gt;&lt;br&gt;
      &lt;% article.errors.full_messages_for(:body).each do |message| %&gt;
        &lt;div&gt;&lt;%= message %&gt;&lt;/div&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  
    &lt;div&gt;
      &lt;%= form.submit %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  <p>and comment model:</p>
  <pre><code>class Comment &lt; ApplicationRecord
    belongs_to :article
  
  end
  </code></pre>
  <p>I am thinking that maybe in show.html is the error because there is title, but it is related to article so guess i'm wrong.
  Thank you very much for any kind of help, i think i am missing something that should perhaps know how to fix.
  (i have checked post with similar content but there was title validation in comment model)</p>