You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/controllers/users/watches_controller.rb

28 lines
511 B

6 years ago
class Users::WatchesController < Users::BaseController
6 years ago
before_action :require_login, :check_auth
6 years ago
def create
if observed_logged_user?
render_error('不能关注自己')
return
end
if current_user.watched?(observed_user)
render_ok
return
end
current_user.watch!(observed_user)
render_ok
end
def destroy
unless current_user.watched?(observed_user)
render_ok
return
end
current_user.unwatch!(observed_user)
render_ok
end
end