Files
growstuff/app/controllers/members_controller.rb
Skud 6ddc0a5e15 Minor tweaks, mostly to formatting
... because I'm picky ;)  I particularly wasn't keen on the search link
on the logged in homepage, which didn't really fit in there.  I also
made the link display on *all* profiles (not just your own), and changed
the way the headings/titles were formatted.

I also changed CanCan to not specify who can search nearby members, but
to skip it in the controller instead.  It just didn't really make sense
in ability.rb.
2013-04-03 15:28:11 +11:00

47 lines
1.1 KiB
Ruby

class MembersController < ApplicationController
load_and_authorize_resource
skip_authorize_resource :only => :nearby
def index
@members = Member.confirmed.paginate(:page => params[:page])
respond_to do |format|
format.html # index.html.haml
end
end
def show
@member = Member.confirmed.find(params[:id])
@posts = @member.posts
# The garden form partial is called from the "New Garden" tab;
# it requires a garden to be passed in @garden.
# The new garden is not persisted unless Garden#save is called.
@garden = Garden.new
respond_to do |format|
format.html # show.html.haml
format.rss { render(
:layout => false,
:locals => { :member => @member }
)}
end
end
def nearby
if !params[:location].blank?
@location = params[:location]
elsif current_member
@location = current_member.location
else
@location = nil
end
@distance = 100
@nearby_members = @location ? Member.near(@location, @distance) : []
respond_to do |format|
format.html # nearby.html.haml
format.json { render json: @nearby_members }
end
end
end