To Examples

TemperatureConverter3 Example

Source code file: TemperatureConverter3/app/controllers/convert_controller.rb:

class ConvertController < ApplicationController

  def input
    @convert_rec = TempConvertRecord.new
  end

  def display
    # The following line was incorrect on 10/21
    # convert_rec = params(pass_params)

    # Here us the corrected line:
    rec = TempConvertRecord.new(pass_params)
    rec.fahr = 9 * rec.cel / 5 + 32
    rec.save

    # Get array to show on display view.
    @recs = TempConvertRecord.all
  end

private

  # Only allow permitted control values from client.
  def pass_params
    params.require(:temp_convert_record).permit(:name, :cel)
  end

end