ADD get project_categories api

dev_forge
Jasder 5 years ago
parent 9ae672719e
commit 1de9265879

@ -0,0 +1,5 @@
class ProjectCategoriesController < ApplicationController
def index
@project_categories = ProjectCategory.search(params[:name]).without_content
end
end

@ -1,8 +1,13 @@
module ProjectAble
module Projectable
extend ActiveSupport::Concern
included do
has_many :projects, -> { order(position: :asc) }
scope :without_content, -> { select(column_names - ['content'])}
scope :search, lambda { |keywords|
where("name LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
}
end
module ClassMethods

@ -1,5 +1,5 @@
class ProjectCategory < ApplicationRecord
include ProjectAble
include Projectable
has_ancestry
end

@ -1,3 +1,3 @@
class ProjectLanguage < ApplicationRecord
include ProjectAble
include Projectable
end

@ -0,0 +1 @@
json.project_categories @project_categories, :id, :name

@ -1,5 +1,4 @@
Rails.application.routes.draw do
Rails.application.routes.draw do
require 'sidekiq/web'
require 'admin_constraint'
mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new
@ -23,6 +22,8 @@ Rails.application.routes.draw do
put 'commons/unhidden', to: 'commons#unhidden'
delete 'commons/delete', to: 'commons#delete'
resources :project_categories, only: [:index, :show]
# resources :memos do
# member do
# post :sticky_or_cancel

Loading…
Cancel
Save