API: Fix find tags by name (#359)

This commit is contained in:
Araslanov Evgeny 2018-08-16 00:01:43 +03:00 committed by Ben Halpern
parent f5a6011191
commit 4ba8296298
2 changed files with 9 additions and 34 deletions

View file

@ -9,43 +9,11 @@ module Api
def index
@page = params[:page]
@tags = Tag.all.order("taggings_count DESC").page(@page).per(10)
@tags = Tag.order(taggings_count: :desc).page(@page).per(10)
end
def onboarding
tag_names = %w[
beginners
career
computerscience
git
go
java
javascript
linux
productivity
python
security
webdev
css
php
opensource
ruby
cpp
dotnet
swift
testing
devops
vim
kotlin
rust
elixir
scala
]
@tags = []
tag_names.each do |tag_name|
@tags.push(Tag.find_by(name: tag_name))
end
@tags = @tags.reject(&:nil?)
@tags = Tag.where(name: Tag::NAMES)
end
end
end

View file

@ -3,6 +3,13 @@ class Tag < ActsAsTaggableOn::Tag
acts_as_followable
resourcify
NAMES = %w(
beginners career computerscience git go java javascript
linux productivity python security webdev css php opensource
ruby cpp dotnet swift testing devops vim kotlin rust elixir
scala
).freeze
mount_uploader :profile_image, ProfileImageUploader
mount_uploader :social_image, ProfileImageUploader