Skip to content

Instantly share code, notes, and snippets.

@beakr
Created April 14, 2013 03:02
Show Gist options
  • Save beakr/5381228 to your computer and use it in GitHub Desktop.
Save beakr/5381228 to your computer and use it in GitHub Desktop.
Neat little widget for Devise greeting the user in a random language.
# coding: utf-8
# Make sure you declare the use of utf-8
# so you can use characters from other
# languages.
module ApplicationHelper
def greeting
# Add more here
greetings = ['Hello', 'Greetings', 'Hi', 'Kon\'nichiwa', 'Bonjour',
'Cześć', 'Olá', 'Hallo', 'Hei', 'Hallå']
# Select a random greeting
greetings.sample
end
end
<%# In your layout somewhere... %>
<% if !user_signed_in? %>
<%= link_to 'Sign in', new_user_session_path %> or <%= link_to 'Sign up', new_user_registration_path %>
<% else %>
<%= greeting %> <% current_user.email %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment