Class: Layered::Assistant::AssistantsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Layered::Assistant::AssistantsController
- Defined in:
- app/controllers/layered/assistant/assistants_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/layered/assistant/assistants_controller.rb', line 19 def create @assistant = Assistant.new(assistant_params.except(:persona_id, :skill_ids)) @assistant.owner = l_ui_current_user @assistant.persona = scoped(Persona).find(assistant_params[:persona_id]) if assistant_params[:persona_id].present? if @assistant.save assign_skills redirect_to layered_assistant.assistants_path, notice: "Assistant was successfully created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
49 50 51 52 |
# File 'app/controllers/layered/assistant/assistants_controller.rb', line 49 def destroy @assistant.destroy redirect_to layered_assistant.assistants_path, notice: "Assistant was successfully deleted." end |
#edit ⇒ Object
32 33 34 |
# File 'app/controllers/layered/assistant/assistants_controller.rb', line 32 def edit @page_title = "Edit assistant" end |
#index ⇒ Object
9 10 11 12 |
# File 'app/controllers/layered/assistant/assistants_controller.rb', line 9 def index @page_title = "Assistants" @pagy, @assistants = pagy(scoped(Assistant).includes(:persona).by_name) end |
#new ⇒ Object
14 15 16 17 |
# File 'app/controllers/layered/assistant/assistants_controller.rb', line 14 def new @page_title = "New assistant" @assistant = Assistant.new end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/layered/assistant/assistants_controller.rb', line 36 def update if assistant_params.key?(:persona_id) @assistant.persona = assistant_params[:persona_id].present? ? scoped(Persona).find(assistant_params[:persona_id]) : nil end if @assistant.update(assistant_params.except(:persona_id, :skill_ids)) assign_skills redirect_to layered_assistant.assistants_path, notice: "Assistant was successfully updated." else render :edit, status: :unprocessable_entity end end |