Meta tags via helper - assistance needed

I am trying to generate meta tags based on the page. The meta_block call
in somepage.html.erb sets :meta_block and it is correctly yielded in
application.html.erb (except that only the last line is output).

But when otherpage.html.erb is rendered, because I don’t call meta_block
there is no meta content output. I thought the “|| meta_block” would
cause the helper to be called if :meta_block was not set.

How do I get all of the metat tags to be output on the page, and how do
I get it to happen if there are no per page keywords and description?

Thanks,

Matt

#application_helpers.rb
def meta_block(description = ‘’, keywords = ‘’)
tag(‘meta’, :‘http-equiv’ => ‘Content-Type’, :content => ‘text/html;
charset=utf-8’)
tag(‘meta’, :‘http-equiv’ => ‘Content-Language’, :content =>
‘en-US,en’)
tag(‘meta’, :name => ‘description’, :content => SITE[:DESCRIPTION] +
description)
tag(‘meta’, :name => ‘keywords’, :content => SITE[:KEYWORDS] +
keywords)
tag(‘meta’, :name => ‘robots’, :content => ‘all’)
end

#somepage.html.erb
<% meta_block(“My per page description.”,“keywords, for this, page”) %>
some page’s content

#otherpage.html.erb
other-page’s content

#application.html.erb

My Application <%= yield(:meta_block) || meta_block %> <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %>
<%= yield %>

module LayoutHelper
def title(page_title, show_title = true)
content_for(:title) { h(page_title.to_s) }
@show_title = show_title
end

def show_title?
@show_title
end

def stylesheet(*args)
content_for(:head) { stylesheet_link_tag(*args) }
end

def javascript(*args)
content_for(:head) { javascript_include_tag(*args) }
end
end

<%= content_for?(:title) ? yield(:title) : "Untitled" %> <%= stylesheet_link_tag :application %> <%= javascript_include_tag :application %> <%= csrf_meta_tag %> <%= yield(:head) %> <% if logged_in? %> Welcome <%= current_user.username %>. <%= link_to "Edit profile", edit_current_user_path %> or <%= link_to "Log out", logout_path %> <% else %> <%= link_to "Sign up", signup_path %> or <%= link_to "log in", login_path %>. <% end %> <% flash.each do |name, msg| %> <%= content_tag :div, msg, :id => "flash_#{name}" %> <% end %> <%= content_tag :h1, yield(:title) if show_title? %> <%= yield %>

check this out

To accept content, showing default if none, in your layout
<%= content_for?(:meta_block) ? yield(:meta_block) : meta_block $>

Called in your content.html.erb that uses the above layout.
<%= content_for(:meta_block) do $>
<%= meta_block(“Yield”, "Got it now!)%>
<% end %>