2

Can anyone help me out with the following? I have a partial view named _menu.html.erb inside a shared folder in views folder. I am trying to render this view inside my pages like so

<%= render "shared/menu" %>

But i am getting the following error.

Missing partial shared/_menu with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}

What am I doing wrong?

Thanks!

Pavan
  • 33,316
  • 7
  • 50
  • 76

2 Answers2

2

Put your menu.html.erb

here

app/views/shared/_menu.html.erb

and then render this with this line

<%= render :partial => "/shared/menu" %>
Pooja Mokariya
  • 1,970
  • 5
  • 21
  • 46
0

If you use just "render" with an argument, it's excpecting an ActiveRecord object, and will look for the "show" partial of this object, like this :

<%= render @user %> #this will render the "user/show" partial for @user

You can render a classical partial like this (without locals if you don't need any arguments) :

<%= render partial: "shared/menu", locals: {my_arg: my_val} %>
Caillou
  • 1,451
  • 10
  • 19