Class: Admin::Api::MenuItemsController
- Inherits:
-
Admin::ApiController
- Object
- Admin::ApiController
- Admin::Api::MenuItemsController
- Defined in:
- app/controllers/admin/api/menu_items_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #initial_data ⇒ Object
- #set_default ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/admin/api/menu_items_controller.rb', line 12 def create = Odania::Menu.where(site_id: params[:site_id], id: params[:menu_id]).first bad_api_request('invalid_menu') if .nil? = Odania::MenuItem.new(content_params) .target_data = odania_target_data_params . = .id if .save if ..nil? and .published . = .id .save end flash[:notice] = t('created') render action: :show else render json: {errors: .errors}, status: :bad_request end end |
#destroy ⇒ Object
43 44 45 46 47 48 |
# File 'app/controllers/admin/api/menu_items_controller.rb', line 43 def destroy .destroy flash[:notice] = t('deleted') render json: {message: 'deleted'} end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/admin/api/menu_items_controller.rb', line 5 def index = Odania::MenuItem.where(menu_id: params[:menu_id]).order('title ASC') end |
#initial_data ⇒ Object
50 51 |
# File 'app/controllers/admin/api/menu_items_controller.rb', line 50 def initial_data end |
#set_default ⇒ Object
53 54 55 56 57 58 59 |
# File 'app/controllers/admin/api/menu_items_controller.rb', line 53 def set_default . = .id .save! = Odania::MenuItem.where(menu_id: .id).order('title ASC') render action: :index end |
#show ⇒ Object
9 10 |
# File 'app/controllers/admin/api/menu_items_controller.rb', line 9 def show end |
#update ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/admin/api/menu_items_controller.rb', line 33 def update .target_data = odania_target_data_params if .update(content_params) flash[:notice] = t('updated') render action: :show else render json: {errors: .errors}, status: :bad_request end end |