Class: PromptCanary::Dashboard::PromptsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PromptCanary::Dashboard::PromptsController
- Defined in:
- app/controllers/prompt_canary/dashboard/prompts_controller.rb
Instance Attribute Summary collapse
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
-
#prompts ⇒ Object
readonly
Returns the value of attribute prompts.
Instance Method Summary collapse
Instance Attribute Details
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
6 7 8 |
# File 'app/controllers/prompt_canary/dashboard/prompts_controller.rb', line 6 def prompt @prompt end |
#prompts ⇒ Object (readonly)
Returns the value of attribute prompts.
6 7 8 |
# File 'app/controllers/prompt_canary/dashboard/prompts_controller.rb', line 6 def prompts @prompts end |
Instance Method Details
#index ⇒ Object
8 9 10 |
# File 'app/controllers/prompt_canary/dashboard/prompts_controller.rb', line 8 def index @prompts = PromptCanary.registered_prompts.map { |klass| build_prompt_data(klass) } end |
#promote ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/controllers/prompt_canary/dashboard/prompts_controller.rb', line 19 def promote klass = PromptCanary.registered_prompts.find { |k| k.name == params[:name] } head(:not_found) && return unless klass PromptCanary.promote(klass, params[:version]) redirect_to prompt_path(params[:name]) end |
#show ⇒ Object
12 13 14 15 16 17 |
# File 'app/controllers/prompt_canary/dashboard/prompts_controller.rb', line 12 def show klass = PromptCanary.registered_prompts.find { |k| k.name == params[:name] } head(:not_found) && return unless klass @prompt = build_prompt_data(klass).merge(events: fetch_events(klass.name)) end |