Unpermitted parameters even though permitted

Viewed 915

I know, that a lot of questions related to strong params have already been asked, but I'm facing a very strange behavior here. I have a model with nested attributes, permitted the right params (I checked for typos like a hundred times) and still get the error:

Unpermitted parameters: :season_start, :season_end

The strange thing about this: there is a third variable in the same nested model which gets accepted!

Here's my relevant code:

class Api::HotelsController < ApiController

  ...

  def hotel_params
    params.require(:hotel).permit(:id, :listing_name, ..., seasons_attributes:[:id, :season_start, :season_end, :period, :_destroy])
  end
end

And my Model:

class Hotel < ApplicationRecord

  ...

  has_many :seasons, dependent: :destroy

  accepts_nested_attributes_for :seasons, update_only: true, allow_destroy: true

end

I have absolutely no idea what could be wrong and tried various things in order to solve the issue but I couldn't figure out, why :period is permitted but :season_start and :season_end are not.

Here's the log message of the received params:

"seasons_attributes"=>[{"period"=>"mid-season", "season_start"=>{}, "season_end"=>{}}]}
0 Answers
Related