Class: Adminpanel::CategoriesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Adminpanel::CategoriesController
- Defined in:
- app/controllers/adminpanel/categories_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/adminpanel/categories_controller.rb', line 17 def create merge_params @resource_instance = @model.new(send(whitelisted_params)) respond_to do |format| if @resource_instance.save format.html { redirect_to categories_path, flash: { success: I18n.t('action.save_success') } } format.js do if params[:currentcontroller].to_s == 'adminpanel/categories' # we are in categories controller render 'create', locals: { category: @resource_instance } elsif params[:belongs_request].present? # we are in other controller as a belongs_to, add option to select render 'adminpanel/shared/create_belongs_to', locals: { resource: @resource_instance } else # we are in other controller as a has_many, add checkbox render 'adminpanel/shared/create_has_many', locals: { resource: @resource_instance } end end else format.html { render 'adminpanel/shared/new' } format.js { render 'new' } end end end |
#destroy ⇒ Object
42 43 44 45 |
# File 'app/controllers/adminpanel/categories_controller.rb', line 42 def destroy @resource_instance.destroy redirect_to categories_path end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/adminpanel/categories_controller.rb', line 5 def index @categories = Category.all end |
#new ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/controllers/adminpanel/categories_controller.rb', line 9 def new @resource_instance = @model.new respond_to do |format| format.html { render 'adminpanel/shared/new' } format.js { render } end end |