Sha256: 8974c472e747601aceccd56f4052f89ac3ba9c3b734c51500277cdd0c2ca6f1d

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

module MuckProfilesHelper

  # Renders a profile edit form
  # content:  Optional content object to be edited.
  # options:  html options for form.  For example:
  #             :html => {:id => 'a form'}
  def profile_form(user, options = {}, &block)
    options[:html] = {} if options[:html].nil?
    raw_block_to_partial('profiles/form', options.merge(:user => user), &block)
  end
  
  # Outputs a link and text that guesses the user's location using their ip.
  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
  
  # Turns a geokit location object into a location string with city, state country
  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
  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
muck-profiles-3.1.5 app/helpers/muck_profiles_helper.rb
muck-profiles-3.1.4 app/helpers/muck_profiles_helper.rb
muck-profiles-3.1.3 app/helpers/muck_profiles_helper.rb
muck-profiles-3.1.2 app/helpers/muck_profiles_helper.rb
muck-profiles-3.1.1 app/helpers/muck_profiles_helper.rb
muck-profiles-3.1.0 app/helpers/muck_profiles_helper.rb
muck-profiles-3.0.2 app/helpers/muck_profiles_helper.rb
muck-profiles-3.0.1 app/helpers/muck_profiles_helper.rb
muck-profiles-3.0.0 app/helpers/muck_profiles_helper.rb
muck-profiles-0.2.1 app/helpers/muck_profiles_helper.rb
muck-profiles-0.2.0 app/helpers/muck_profiles_helper.rb