Class: Admin::DictionariesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Admin::DictionariesController
- Defined in:
- lib/generators/open_loam/install/templates/admin/dictionaries_controller.rb
Overview
Managed lookup lists (OpenLoam::Dictionary) — manager-only. The index lists a tenant's dictionaries; the edit screen curates a dictionary's entries (Admin::DictionaryEntriesController). Tenant-scoped by the model's default scope, so a manager only ever sees their own tenant's lists.
Constant Summary
Constants included from Pagination
Instance Method Summary collapse
Methods inherited from BaseController
Methods included from Pagination
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/generators/open_loam/install/templates/admin/dictionaries_controller.rb', line 18 def create @dictionary = OpenLoam::Dictionary.new(dictionary_params) if @dictionary.save redirect_to edit_admin_dictionary_path(@dictionary), notice: "Dictionary created — add its entries below." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
40 41 42 43 |
# File 'lib/generators/open_loam/install/templates/admin/dictionaries_controller.rb', line 40 def destroy @dictionary.destroy! redirect_to admin_dictionaries_path, notice: "Dictionary deleted." end |
#edit ⇒ Object
27 28 29 |
# File 'lib/generators/open_loam/install/templates/admin/dictionaries_controller.rb', line 27 def edit @entry = @dictionary.entries.new(active: true) end |
#index ⇒ Object
10 11 12 |
# File 'lib/generators/open_loam/install/templates/admin/dictionaries_controller.rb', line 10 def index @dictionaries = OpenLoam::Dictionary.order(:key) end |
#new ⇒ Object
14 15 16 |
# File 'lib/generators/open_loam/install/templates/admin/dictionaries_controller.rb', line 14 def new @dictionary = OpenLoam::Dictionary.new end |
#update ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/generators/open_loam/install/templates/admin/dictionaries_controller.rb', line 31 def update if @dictionary.update(dictionary_params) redirect_to admin_dictionaries_path, notice: "Dictionary updated." else @entry = @dictionary.entries.new render :edit, status: :unprocessable_entity end end |