Manually creating parameter hash in rails

September 23rd | By | Back to Blog

As of Rails 4.0 and the introduction of Strong Parameters creating a hash with indifferent access is a bit problematic because you need to require and permit on the parameters hash, the solution I found is

  raw_parameters = { 
    :foo => {
      :butter => "fat", 
      :cheese => "cheddar", 
    :bar => {
      :fork => "pointy",
      :knife => "sharp",

  params =

  params.require(:foo).permit(:butter, :cheese)
  params.require(:bar).permit(:fork, :knife)

Happy coding!

  • Aaron

    I LOVE YOU!!!! I SO SO SO SO LOVE YOU! Two days to find that solution!