metamaps--metamaps/app/controllers/users_controller.rb

45 lines
1.1 KiB
Ruby
Raw Normal View History

2012-09-23 02:39:12 +00:00
class UsersController < ApplicationController
before_filter :require_user, only: [:edit, :update]
2012-09-23 02:39:12 +00:00
respond_to :html, :json
2012-12-16 20:00:43 +00:00
autocomplete :user, :name, :full => true
2012-09-23 02:39:12 +00:00
# GET /user/edit
def edit
@user = current_user
respond_with(@user)
end
# GET /user/:id
2012-09-23 02:39:12 +00:00
def show
@user = User.find(params[:id])
@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-23 02:39:12 +00:00
2013-01-08 00:57:04 +00:00
respond_with(@user, @topics, @synapses, @maps)
2012-09-23 02:39:12 +00:00
end
# PUT /user
def update
@user = current_user
@user.attributes = params[:user]
@m = params[:metacodes][:value]
@user.settings.metacodes=@m.split(',')
2012-09-23 02:39:12 +00:00
@user.save
respond_with(@user, location: user_url(@user)) do |format|
2012-09-23 02:39:12 +00:00
end
end
end