forked from gotealeaf/myflix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea384b1
commit f68387f
Showing
5 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
class QueueItemsController < ApplicationController | ||
before_action :require_user | ||
|
||
def index | ||
@queue_items = current_user.queue_items | ||
end | ||
|
||
def create | ||
video = Video.find(params[:video_id]) | ||
queue_video(video) | ||
redirect_to my_queue_path | ||
end | ||
|
||
private | ||
|
||
def queue_video(video) | ||
QueueItem.create(video: video, user: current_user, position: new_queue_item_position) unless current_user_queued_video?(video) | ||
end | ||
|
||
def new_queue_item_position | ||
current_user.queue_items.count + 1 | ||
end | ||
|
||
def current_user_queued_video?(video) | ||
current_user.queue_items.map(&:video).include?(video) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters