0

Im trying to accomplish some functionality in the update method of my model. However, I am getting the following errors which seem to be due to the strong parameter convention introduced in rails 4.

 Upload.rb (Model)
 Update method 

  def update
mode = nil
market = nil
case @upload.task_id
when 1
    mode = "channel"
    market = nil
when 2
    mode = "national"
    market = "national"
when 3
    mode = "regional"
    market = "t"
when 4
    mode = "regional"
    market = "c"
when 5
    mode = "regional"
    market = "e"
when 6
    mode = "regional"
    market = "v"
else
    puts"Error!! Received invalid task.id to parse"
end
options = Hash[:file_path =>Upload.find(params[:id]).f_path , :mode =>"#{mode}", :market=>"#{market}"]
puts "options= #{options.inspect}"
@cp = CsvParser.new(options)

if @upload.update(upload_params)
       redirect_to @upload, notice: 'Upload was successfully updated.'
    else
       render action: 'edit'
    end
  end


  # Only allow a trusted parameter "white list" through.
    def upload_params
    params.require(:upload).permit(:sourcedata, :task_id, :status, :file_path, :options, :mode, :market)
    end

Error

    ActionController::ParameterMissing - param not found: upload:

    actionpack (4.0.0) lib/action_controller/metal/strong_parameters.rb:173:in `require'

What am I doing wrong in the above code. Why cant I send my params through. What should I tweak to make this work. Im a bit confused about the strong params and would appreciate it if someone has any advice. Googling around on the internet I got unrelated stuff so wondering if someone can help.

Thanks,

banditKing
  • 9,405
  • 28
  • 100
  • 157

1 Answers1

0

ActionController::ParameterMissing is basically saying that the current request didn't comply with params.require(:upload) i.e. params[:upload] is not present.

Looks like the issue is not on your update action but on your edit action or within the edit view in the way you are building the form. You should post your def edit code and the edit.html.erb or whatever view is building the update form to further troubleshoot this.

Leo Gallucci
  • 16,355
  • 12
  • 77
  • 110