Class: FollowsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/follows_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /:username/follow



15
16
17
18
# File 'app/controllers/follows_controller.rb', line 15

def create
  Observe.create!(from_user: current_user, to_user: @user)
  redirect_to "/" + params[:username]
end

#destroyObject

DELETE /:username/follow



21
22
23
24
# File 'app/controllers/follows_controller.rb', line 21

def destroy
  Observe.find_by(from_user: current_user, to_user: @user).destroy
  redirect_to "/" + params[:username]
end

#followedObject

GET /:username/followed



10
11
12
# File 'app/controllers/follows_controller.rb', line 10

def followed
  @observes = @user.observed_users
end

#indexObject

GET /:username/follows



5
6
7
# File 'app/controllers/follows_controller.rb', line 5

def index
  @observes = @user.observe_users
end