scinote-web/app/controllers/step_components/tables_controller.rb

26 lines
724 B
Ruby
Raw Normal View History

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),
2022-05-06 17:59:22 +08:00
contents: { data: Array.new(5, Array.new(5, '')) }.to_json,
created_by: current_user
))
end
2022-05-06 17:59:22 +08:00
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