Skip to content

Instantly share code, notes, and snippets.

@clowder
Created March 12, 2013 17:19
Show Gist options
  • Save clowder/5144916 to your computer and use it in GitHub Desktop.
Save clowder/5144916 to your computer and use it in GitHub Desktop.
Seo Tags in Rails
class ApplicationController < ActionController::Base
helper_method :meta_title, :meta_description
private
attr_reader :meta_title, :meta_description
def set_meta_title(title)
@meta_title = title
end
def set_meta_description(description)
@meta_description = description
end
end
class SomeController < ApplicationController
def index
set_meta_title 'Look at me!'
set_meta_description 'Something longer here...'
end
end
!!!
%html
%head
%meta{:content => meta_description}
%title= meta_title || "Default Title"
%body
= yield
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment