October 18

0 comments

Ruby on Rails – Setting the accepted parameters to allow hashes.

By Christopher Mendla

October 18, 2016


Last Updated on November 30, 2019 by Christopher G Mendla

There are times when you need to store a hash/array in a field in a rails table. 

By declaring a hash and putting it at the end of the params permit section, then the data from things such as a multi select will be stored as a hash. Adding => [] declares the field as a hash field. 


def 
search_params
params.require(:search).permit(:document_title,
:summary,
:owner,
:category,
:file_name,
:doc_to_email,
:category => [],
:owner => [])

Christopher Mendla

About the author

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}