I recently performed a migration turning a string column into a Postgres array. The migration was as follows:
def change
change_column :projects, :layout_slug, "varchar[] USING (string_to_array(layout_slug, ','))"
end
Now, I'm running into an issue with Unpermitted parameters: layout_slug. I've tried all of the accepted answers for the other StackOverflow questions and they're still not working for me. Here are all of the variations I've tried so far:
def project_params
params.require(:project).permit(:image_slug, { layout_slug: [] }, :category, ..., :selection => [:inputs => Project::ALLOWED_INPUTS.keys])
end
def project_params
params.require(:project).permit(:image_slug, { :layout_slug => [] }, :category, ..., :selection => [:inputs => Project::ALLOWED_INPUTS.keys])
end
I then tried removing the brackets around :layout_slug => [] and I got an error:
SyntaxError (/.../app/controllers/api/v1/projects_controller.rb:62: syntax error, unexpected ',', expecting =>
... :layout_slug => [], :category, :subcategory, :version, :ema...
... ^
/.../app/controllers/api/v1/projects_controller.rb:62: syntax error, unexpected ')', expecting keyword_end
/.../app/controllers/api/v1/projects_controller.rb:165: syntax error, unexpected end-of-input, expecting keyword_end):
# THIS ONE THROWS A SYNTAX ERROR
def project_params
params.require(:project).permit(:image_slug, :layout_slug => [], :category, :subcategory, :version, :email, :zip_code, :selection => [:inputs => Project::ALLOWED_INPUTS.keys])
end
So then I moved layout_slug to the end, and it went back to throwing the Unpermitted parameters: layout_slug error again.
# This throws the same Unpermitted parameters error as before
def project_params
params.require(:project).permit(:image_slug, ..., :selection => [:inputs => Project::ALLOWED_INPUTS.keys], :layout_slug => [])
end
I've double- and triple-checked the spelling, and I've verified that the front-end is submitting an Array.
What am I missing?? Was there something wrong with my migration? Or is there something blatantly wrong with my permit method?