metamaps--metamaps/app/helpers/application_helper.rb

27 lines
834 B
Ruby
Raw Normal View History

2016-03-25 04:26:07 +00:00
module ApplicationHelper
def get_metacodeset
2016-03-25 04:26:07 +00:00
@m = current_user.settings.metacodes
set = @m[0].include?('metacodeset') ? MetacodeSet.find(@m[0].sub('metacodeset-', '').to_i) : false
set
end
def user_metacodes
2016-03-25 04:26:07 +00:00
@m = current_user.settings.metacodes
set = get_metacodeset
@metacodes = if set
set.metacodes.to_a
else
Metacode.where(id: @m).to_a
end
@metacodes.sort! { |m1, m2| m2.name.downcase <=> m1.name.downcase }.rotate!(-1)
end
2016-09-18 15:22:51 +00:00
def user_metacode
current_user.settings.metacode_focus ? Metacode.find(current_user.settings.metacode_focus.to_i) || user_metacodes()[0] : user_metacodes()[0]
end
2016-03-25 04:26:07 +00:00
def determine_invite_link
"#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : '')
2016-03-25 04:26:07 +00:00
end
2012-09-23 02:39:12 +00:00
end