2012-09-22 22:39:12 -04:00
|
|
|
class UsersController < ApplicationController
|
|
|
|
|
2012-10-26 06:04:52 -04:00
|
|
|
before_filter :require_user, only: [:edit, :update]
|
2012-09-22 22:39:12 -04:00
|
|
|
|
|
|
|
respond_to :html, :json
|
|
|
|
|
2012-12-16 15:00:43 -05:00
|
|
|
autocomplete :user, :name, :full => true
|
2013-07-11 11:13:27 -04:00
|
|
|
|
2012-09-22 22:39:12 -04:00
|
|
|
|
|
|
|
# GET /user/edit
|
|
|
|
def edit
|
|
|
|
@user = current_user
|
|
|
|
|
|
|
|
respond_with(@user)
|
|
|
|
end
|
|
|
|
|
2013-01-18 17:08:06 -05:00
|
|
|
# GET /user/:id
|
2012-09-22 22:39:12 -04:00
|
|
|
def show
|
2012-10-26 06:59:45 -04:00
|
|
|
@user = User.find(params[:id])
|
2013-01-18 17:08:06 -05:00
|
|
|
@topics = Topic.visibleToUser(@current, @user).sort! { |a,b| b.created_at <=> a.created_at }
|
|
|
|
@topics = @topics.slice(0,3)
|
|
|
|
@synapses = Synapse.visibleToUser(@current, @user).sort! { |a,b| b.created_at <=> a.created_at }
|
|
|
|
@synapses = @synapses.slice(0,3)
|
|
|
|
@maps = Map.visibleToUser(@current, @user).sort! { |a,b| b.created_at <=> a.created_at }
|
|
|
|
@maps = @maps.slice(0,3)
|
2012-09-22 22:39:12 -04:00
|
|
|
|
2013-01-07 19:57:04 -05:00
|
|
|
respond_with(@user, @topics, @synapses, @maps)
|
2012-09-22 22:39:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
# PUT /user
|
|
|
|
def update
|
|
|
|
@user = current_user
|
|
|
|
@user.attributes = params[:user]
|
|
|
|
|
2013-01-25 20:49:40 -05:00
|
|
|
@m = params[:metacodes][:value]
|
|
|
|
@user.settings.metacodes=@m.split(',')
|
|
|
|
|
2012-09-22 22:39:12 -04:00
|
|
|
@user.save
|
|
|
|
|
2012-10-26 06:04:52 -04:00
|
|
|
respond_with(@user, location: user_url(@user)) do |format|
|
2012-09-22 22:39:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|