Class: GuiderCms::SubcategoriesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- GuiderCms::SubcategoriesController
- Defined in:
- app/controllers/guider_cms/subcategories_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/guider_cms/subcategories_controller.rb', line 15 def create classification = params[:subcategory]["category"] subcategory = params[:subcategory]["subcategory"] # puts(classification) # # category = Category.find_by(classification: classification) puts(category.id) category.children.create(classification: subcategory) @root = category.ancestors.last.classification redirect_to content_new_back_path(root: @root) end |
#new ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/guider_cms/subcategories_controller.rb', line 5 def new if current_user && is_guider_admin @root = params[:root] @root_category = Category.find_by(classification: @root) @categories = Category.where(parent_id: @root_category.id) else redirect_to content_new_back_path(root: @root) end end |