Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve scheduler visual run handling of return value from update method #2165

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/schedulers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def visual_run
begin
require mod_name
output = Updater.update(action.course)
if output
if output.respond_to?(:to_str)
fork_log << "----- Script Output -----\n"
fork_log << output
fork_log << "\n----- End Script Output -----"
Expand Down
6 changes: 6 additions & 0 deletions docs/features/schedulers.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ end
You can run a scheduler manually by clicking the `Run` button. This is useful for ensuring the code's correctness.

To assist in debugging, you can return a string from the `update` method, which will be displayed as output in the browser.
You should return `nil` to represent no output.

!!! info "Output String"
If you do not explicitly return a value, this might lead to unexpected outputs due to Ruby's implicit return values.

The return value will be converted to a string if possible, else it will be treated as no output.

**Example file**
```ruby
Expand Down