class InternalChangeNotesController < ApplicationController
  def create
    InternalChangeNote.create(internal_change_note_params.merge(step_by_step_page_id: step_by_step_page.id, created_at: Time.now, author: current_user.name))
    redirect_to step_by_step_page_internal_change_notes_path, notice: 'Change note was successfully added.'
  end

private

  def step_by_step_page
    StepByStepPage.find(params[:step_by_step_page_id])
  end

  def internal_change_note_params
    params.require(:internal_change_note).permit(:description)
  end
end

class InternalChangeNotesController < ApplicationController
  def create
    InternalChangeNote.create(required_fields.merge(other_fields))
    redirect_to step_by_step_page_internal_change_notes_path, notice: 'Change note was successfully added.'
  end

private

  def step_by_step_page
    StepByStepPage.find(params[:step_by_step_page_id])
  end

  def required_fields
    params.require(:internal_change_note).permit(:description)
  end

  def other_fields
    {
      step_by_step_page_id: step_by_step_page.id,
      created_at: Time.now,
      author: current_user.name
    }
  end
end

Refactor how an InternalChangeNote is stored
Refactor how an InternalChangeNote is stored

This refactor will make it easier to optionally add a value for edition_number to the `other_fields` in the next commit.
