title: Ruby on Rails nil value
body: <p>I somehow broke my application and can't seem to find my mistake and would appreciate some help a lot.</p>
  
  <pre><code>&lt;%= debug @relquotes %&gt;
   &lt;%= debug @book%&gt;
    &lt;h4 class="text-center"&gt;Related Quotes&lt;/h4&gt;
    &lt;% @relquotes.each do |quote| %&gt;
      &lt;article class="blog-1 blog-archive py-5"&gt;
        &lt;div class="col-12 col-md-8 mr-md-auto ml-md-auto"&gt;
          &lt;ol class="list-unstyled"&gt;
            &lt;li&gt;
              &lt;h2 class="leading-normal mb-3"&gt;&lt;%= quote.title %&gt;&lt;/h2&gt;
              &lt;div class="article-meta color-grey-50"&gt;
                &lt;div class="media-body d-flex align-items-center"&gt;
                  &lt;p class="m-0 media-heading"&gt;&lt;a&gt;by &lt;/a&gt;&lt;%= link_to quote.user.username, user_path(quote.user) %&gt; &amp;bull;
                    created &lt;%= time_ago_in_words(quote.created_at) %&gt; ago&lt;/p&gt;
                &lt;/div&gt;
              &lt;/div&gt;
              &lt;p class="quotebody"&gt;&lt;%= sanitize quote.body.first(240) %&gt; (...)&lt;/p&gt;
              &lt;a&gt;  &lt;%= link_to quote do %&gt; Read more &amp;rarr;&lt;/a&gt;
                &lt;% end %&gt;
                &lt;/ol&gt;
        &lt;/div&gt;
      &lt;/article&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p>Got this on my Book view and I have related quotes from books that I want to display with this</p>
  
  <pre><code>class Quote &lt; ApplicationRecord
    belongs_to :user
    belongs_to :category
    belongs_to :book
    has_many :comments, dependent: :destroy
  
  
    validates :title, presence: true, length: {minimum: 5}
    validates :body, presence: true, length: {minimum: 240}
  end
  
  class Book &lt; ApplicationRecord
    belongs_to :user, optional: true
    belongs_to :category, optional: true
    has_many :quotes
    has_many :reviews, dependent: :destroy
  
    has_attached_file :book_cover, styles: {book_index: '250x350&gt;', book_show: '325x475&gt;'}
    validates_attachment_content_type :book_cover, content_type: /\Aimage\/.*\z/
  end
  </code></pre>
  
  <p>My books controller</p>
  
  <pre><code>class BooksController &lt; ApplicationController
    layout "_app_nav"
  
    before_action :set_book, only: [:show, :edit, :update, :destroy]
  
    # GET /books/1
    def show
      @average_review = if @book.reviews.blank?
                          0
                        else
                          @book.reviews.average(:rating).round(2)
                        end
      @relquotes = @book.quotes
  
    end
  
    private
  
    # Use callbacks to share common setup or constraints between actions.
    def set_book
      @book = Book.find(params[:id])
    end
  
    # Only allow a trusted parameter "white list" through.
    def book_params
      params.require(:book).permit(:title, :author, :description, :user_id, :book_cover, :category_id)
    end
  end
  </code></pre>
  
  <p>The debug @book works fine and my book gets displayed. I confirmed via rails console that the quote is associated with the book.
  The debug @relquotes resolves in plain '--- []'.
  It was working before and I cant seem to find where I messed it up.</p>
  
  <p>My <code>@relquotes</code> should display all the quotes that are associated with a book. I can confirm that quotes are associated with a book.</p>
  
  <p>eg. quote has book_id = 1 - therefore the book with the book_id 1 should display this quote as a 'related quote'. 
  Any help would be appreciated.</p>
  
  <p>Thanks in advance!</p>