scinote-web/app/controllers/step_components/tables_controller.rb
2022-05-06 12:09:54 +02:00

25 lines
724 B
Ruby

module StepComponents
class TablesController < StepOrderableElementsController
private
def create_step_element
@step.step_tables.create!(table:
Table.create!(
name: t('protocols.steps.table.default_name', position: @step.step_tables.length + 1),
contents: { data: Array.new(5, Array.new(5, '')) }.to_json,
created_by: current_user
))
end
def orderable_params
params.permit(:name, :contents)
end
def load_vars
@element = @step.tables.find_by(id: params[:id])
@orderable_element = @element.step_table.step_orderable_elements.find_by(step: @step)
return render_404 unless @element && @orderable_element
end
end
end