Skip to content

Instantly share code, notes, and snippets.

@adamcarlile
Created March 12, 2011 03:57
Show Gist options
  • Save adamcarlile/867013 to your computer and use it in GitHub Desktop.
Save adamcarlile/867013 to your computer and use it in GitHub Desktop.
Render user status examples
def render_user_status
if user_signed_in?
inner_html = content_tag(:span, "Signed in as #{current_user.email}. Not you? \n #{link_to("Sign out", destroy_user_session_path)}")
else
inner_html = content_tag(:span, "#{link_to("Sign up", new_user_registration_path)} \n or \n #{link_to("Sign in", new_user_session_path)}")
end
return content_tag(:div, inner_html, :id => "user_nav")
end
def render_user_status
xhtml = Builder::XmlMarkup.new :target => out=(''), :indent => 2
xhtml.div(:id => "user_nav") do |x|
if user_signed_in?
x << "Signed in as #{current_user.email}. Not you? "
x << link_to("Sign out", destroy_user_session_path)
else
x << link_to("Sign up", new_user_registration_path)
x << " or "
x << link_to("Sign in", new_user_session_path)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment