Search code examples
ruby-on-railsviewrenderpartial

Ruby On Rails Rendering Partial


Hi I am having problems with rendering a partial in a rails view.

I created a partial called _my_header.html.erb in the views/layouts directory.

Then in another file in a different folder in the views called index.html.erb I added:

 <% render 'layouts/my_header' %>

I put this inside a html tag. Anyway I am getting this error:

ActionView::MissingTemplate in User#index

Showing C:/Buzzoo/Buzzoo/app/views/user/index.erb where line #2 raised:
Extracted source (around line #2):

1: <html>
2:  <% render 'layouts/my_header' %>
3: 
4:  <body>

Solution

  • ActionView::MissingTemplate in Player#index Showing C:/Buzzoo/Buzzoo/app/views/player/index.mobile.erb where line #2 raised: Missing partial /layouts/mobile_header with {:locale=>[:en], :formats=>[:mobile], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "C:/Buzzoo/Buzzoo/app/views" * "C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/devise-2.1.2/app/views" Extracted source (around line #2): 1: 2: <%= render '/layouts/mobile_header' %> 3: 4:

    @user2527785

    The above error specifies that there is no partials in the name of mobile_header. Are you sure you have a partial _mobile_header.mobile.erb in your layouts?