From fed8ce2c1785da5690f46a79a82e8a198cc4f107 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Thu, 28 Mar 2013 12:40:18 +0000 Subject: [PATCH] Allow setting location in members/:id/nearby It currently doesn't actually do anything, but the thought's there. --- app/controllers/members_controller.rb | 1 + app/views/members/nearby.html.haml | 21 ++++++++++++++++++--- app/views/members/show.html.haml | 3 +++ config/routes.rb | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index c08fcd99b..9abaeac53 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -26,6 +26,7 @@ class MembersController < ApplicationController end def nearby + @location = params[:location] || current_member.location @nearby_members = [current_member] respond_to do |format| format.html # nearby.html.haml diff --git a/app/views/members/nearby.html.haml b/app/views/members/nearby.html.haml index 638a963ac..857b5f4b4 100644 --- a/app/views/members/nearby.html.haml +++ b/app/views/members/nearby.html.haml @@ -1,8 +1,23 @@ -- content_for :title, "Members near you" +- if @location != current_member.location + - content_for :title, "Members near #{@location}" +- else + - content_for :title, "Members near you" + += link_to "Edit your location", edit_member_registration_path(current_member) + += form_tag(nearby_members_path(current_member), :html => { :method => :get, :class => 'form-horizontal' }) do + + .control-group + = label_tag :location, "Location", :class => 'control-label' + .controls + = text_field_tag :location, @location + + .form-actions + = submit_tag "Search", :class => 'btn btn-primary' %ul - @nearby_members.each do |member| %li = link_to(member.login_name, member) - , - = member.location + - if member.location + , #{@member.location} diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 956c12e10..9f9ab81ea 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -14,6 +14,9 @@ = @member.location %br/ = image_tag("http://maps.google.com/maps/api/staticmap?size=200x200&maptype=roadmap&sensor=false&markers=color:green|label:A|#{@member.latitude},#{@member.longitude}&zoom=12", :alt => "Map showing #{@member.location}", :width => 200, :height => 200 ) + - if current_member == @member + %p + = link_to 'Show nearby members', nearby_members_path(@member) - if @member.show_email %p Email: diff --git a/config/routes.rb b/config/routes.rb index c485022ff..18aae03c0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,7 +15,7 @@ Growstuff::Application.routes.draw do get "home/index" - match 'members/:id/nearby' => 'members#nearby' + match 'members/:id/nearby' => 'members#nearby', :as => :nearby_members # The priority is based upon order of creation: # first created -> highest priority.