title: Rendering partials anywhere on your rails app
body: <p>I have a conversation partial with route being resources:conversations, but when i try to render this partial in my navigation bar (to list all their active conversations), i get an undefined method error. </p>
  
  <pre><code>undefined method `author' for nil:NilClass
  </code></pre>
  
  <p>Right now i'm doing <code>&lt;%= render 'conversations/conversation' %&gt;</code> </p>
  
  <p>Is there a special way to render your partials ANYWHERE on your website?</p>
  
  <p>EDIT: Providing codes</p>
  
  <p>conversations/_conversation.html.erb</p>
  
  <pre><code>&lt;div&gt;
    From &lt;strong&gt;&lt;%= conversation.author.email %&gt;&lt;/strong&gt; to
    &lt;strong&gt;&lt;%= conversation.receiver.email %&gt; (&lt;%#= conversation.receiver.online? ? 'online' : 'offline' %&gt;)&lt;/strong&gt;
    &lt;br&gt;
    &lt;%= link_to 'View conversation', conversation_path(conversation) %&gt;
    &lt;hr&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>layouts/_navigation.html.erb</p>
  
  <pre><code>  &lt;%= render 'conversations/conversation' %&gt;
  </code></pre>
  
  <p>routes</p>
  
  <pre><code>  #Chat
    resources :conversations
    resources :personal_messages
    resources :users
    mount ActionCable.server =&gt; '/cable'
  </code></pre>
  
  <p>EDIT2: </p>
  
  <p>conversations_controller.rb</p>
  
  <pre><code>class ConversationsController &lt; ApplicationController
    before_action :set_conversation
    before_action :check_participating!, except: [:index]
  
    def index
      @conversations = Conversation.participating(current_user).order('updated_at DESC')
      respond_to do |format|
        format.html
        format.js
      end
    end
  
    def show
      @personal_message = PersonalMessage.new
      @conversations = Conversation.participating(current_user)
    end
  
    private
  
    def set_conversation
      @conversation = Conversation.find_by(id: params[:id])
    end
  
    def check_participating!
      redirect_to root_path unless @conversation &amp;&amp; @conversation.participates?(current_user)
    end
  end
  </code></pre>
  
  <p>applicationcontroller</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    # Prevent CSRF attacks by raising an exception.
    # For APIs, you may want to use :null_session instead.
    protect_from_forgery with: :exception
  
    before_action :authenticate_user!
  
  end
  </code></pre>