Skip to content

Instantly share code, notes, and snippets.

@mikeatlas
mikeatlas / new_invitation.html.erb
Last active April 17, 2022 19:36
How to invite users in active admin with devise_invitable
<!-- /app/views/admin/users/new_invitiations.html.erb -->
<h2>Send invitation</h2>
<%= form_for @user, :url => send_invitation_admin_users_path do |f| %>
<table style='width: 50%'>
<tr>
<td><%= f.label :first_name %></td>
<td><%= f.text_field :first_name %></td>
@natew
natew / reddit_rank.rb
Created October 16, 2012 06:23
Reddit ranking algorithm in rails
# Ranking algorithm
def set_rank
find_id = matching_id || id
shared_song = Song.find(find_id) if find_id
if shared_song
favs_count = shared_song.user_broadcasts_count
time_created = shared_song.created_at
else
favs_count = 1
time_created = created_at