Class: CompletionKit::SuggestionsController
Constant Summary
ApplicationController::ONBOARDING_DISMISS_COOKIE
Instance Method Summary
collapse
Instance Method Details
#apply ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/completion_kit/suggestions_controller.rb', line 10
def apply
if @suggestion.applied_at?
redirect_to suggestion_path(@suggestion), notice: "Suggestion already applied."
return
end
unless @suggestion.ready?
redirect_to suggestion_path(@suggestion), alert: "This suggestion isn't ready to apply yet."
return
end
run = @suggestion.run
new_prompt = run.prompt.clone_as_new_version(template: @suggestion.suggested_template)
new_prompt.publish!
@suggestion.update!(applied_at: Time.current)
redirect_to prompt_path(new_prompt), notice: "Suggestion applied."
end
|
#show ⇒ Object
5
6
7
8
|
# File 'app/controllers/completion_kit/suggestions_controller.rb', line 5
def show
@run = @suggestion.run
@from = params[:from] == "run" ? "run" : "prompt"
end
|