Reputation: 61
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!
Upvotes: 2
Views: 88
Reputation: 1500
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} %>
Upvotes: 0
Reputation: 2120
Put your menu.html.erb
here
app/views/shared/_menu.html.erb
and then render this with this line
<%= render :partial => "/shared/menu" %>
Upvotes: 2