Ask A Question


You’re not receiving notifications from this thread.

How do I make certain partials show everywhere (ie navbar)?

Masud Hossain asked in General

I'm trying to have my 'conversations' partial which is a list of all active conversations show up on the navbar, but of course I'm getting a no method error.

I figured you can copy the conversationscontroller's instance variables and add them to the applicationcontroller, but i think there's a bit more to it than that.

Is there a video on for working with stuff like this?


I don't have a video on it, but that's a good topic. My Guides link in the navbar is actually like this.

What you want to do is setup a before_action to set your instance variables so you can use them in your partials that you include on every page. That will set it up so that you always have them available and can display them on every page.

I'll have to make a screencast on this as well!


before_action is definitely the way to go! Just treat it like any other method... I use this for a contact form on every page...

before_action :set_contact

 def set_contact
    @contact =

then your partial is setup as you'd expect:

<%= form_for @contact, url: user_contact_path do |form| %>
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,969+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.