Skip to content

Instantly share code, notes, and snippets.

@dzjin
Created May 8, 2014 21:04
Show Gist options
  • Save dzjin/127a8ad9279a5a739c57 to your computer and use it in GitHub Desktop.
Save dzjin/127a8ad9279a5a739c57 to your computer and use it in GitHub Desktop.
def usertags
if params[:tags] != nil
@tags = params[:tags]
session[:tags] = @tags
@videos = Video.tagged_with(session[:tags]).order("views DESC").page params[:page]
else
session[:tags] = nil
@videos = Video.order(views: :desc).page params[:page]
end
respond_to do |format|
if session[:tags] == nil
redirect_to videos_path, notice: 'Tags have been cleared.'
else
format.js
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment