forked from saurabh/orbit4-5
Added category and fix routing
This commit is contained in:
parent
2147d87dfe
commit
f6c6efcdc0
|
@ -0,0 +1,11 @@
|
|||
class Category
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :disable, type: Boolean, default: false
|
||||
field :title, localize: true
|
||||
|
||||
belongs_to :module_app
|
||||
|
||||
scope :enabled, ->{ where(:disable.in => [false, nil, ''])}
|
||||
end
|
|
@ -6,6 +6,8 @@ class ModuleApp
|
|||
field :key, type: String
|
||||
field :sidebar_order,type: Integer,default: 0
|
||||
|
||||
has_many :categories, dependent: :destroy, :autosave => true
|
||||
|
||||
def get_registration
|
||||
OrbitApp::Module::Registration.find_by_key(key)
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ OrbitStore::Application.routes.draw do
|
|||
# You can have the root of your site routed with "root"
|
||||
root 'pages#home'
|
||||
|
||||
locales = Site.find_by(site_active: true).in_use_locales rescue nil
|
||||
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
||||
|
||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||
resources :users
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
module OrbitCategory
|
||||
module Categorizable
|
||||
def self.included(base)
|
||||
base.field :category_id, type: BSON::ObjectId
|
||||
end
|
||||
|
||||
def category
|
||||
Category.find(self.category_id) rescue nil
|
||||
end
|
||||
|
||||
def category=(cate)
|
||||
self.category_id = Category.find(cate.id).id rescue nil
|
||||
end
|
||||
|
||||
def disable?
|
||||
Category.find(self.category_id).disable? rescue nil
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue