7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/observ/scores_controller.rb', line 7
def create
value = parse_score_value(params[:value], params[:data_type])
@score = @scoreable.scores.find_or_initialize_by(
name: params[:name] || "manual",
source: :manual
)
@score.assign_attributes(
value: value,
data_type: params[:data_type] || :boolean,
comment: params[:comment],
created_by: params[:created_by]
)
if @score.save
respond_to do |format|
format.turbo_stream
format.html { redirect_back(fallback_location: root_path, notice: "Score saved.") }
end
else
respond_to do |format|
format.turbo_stream { render :create_error, status: :unprocessable_content }
format.html { redirect_back(fallback_location: root_path, alert: "Failed to save score.") }
end
end
end
|