Module: MuckProfilesHelper

Defined in:
app/helpers/muck_profiles_helper.rb

Instance Method Summary collapse

Instance Method Details

#location_suggestion(field_id) ⇒ Object

Outputs a link and text that guesses the user’s location using their ip.



13
14
15
16
17
18
# File 'app/helpers/muck_profiles_helper.rb', line 13

def location_suggestion(field_id)
  geo = Geokit::Geocoders::MultiGeocoder.geocode(request.ip)
  location = readable_location(geo)
  return '' if location.blank?
  render :partial => 'profiles/location_suggestion', :locals => { :field_id => field_id, :location => location }
end

#profile_form(user, options = {}, &block) ⇒ Object

Renders a profile edit form content: Optional content object to be edited. options: html options for form. For example:

:html => {:id => 'a form'}


7
8
9
10
# File 'app/helpers/muck_profiles_helper.rb', line 7

def profile_form(user, options = {}, &block)
  options[:html] = {} if options[:html].nil?
  raw_block_to_partial('profiles/form', options.merge(:user => user), &block)
end

#readable_location(location) ⇒ Object

Turns a geokit location object into a location string with city, state country



21
22
23
24
# File 'app/helpers/muck_profiles_helper.rb', line 21

def readable_location(location)
  return '' if location.city.blank? && location.state.blank? && location.province.blank? && location.country_code.blank?
  "#{location.city}, #{location.state || location.province} #{location.country_code}"
end