RailsCasts Pro episodes are now free!

Learn more or hide this

Alan Ruth's Profile

GitHub User: alanruth

Site: http://www.servelife.com

Comments by Alan Ruth

Avatar

Actually I got that wrong... Here is the code that worked for me. Again the link I put in the initial response was where I got this code...

Products Controller
def product_params
    params.require(:product).permit(:name, :product_type_id).tap do |whitelisted|
        whitelisted[:properties] = params[:product][:properties]
end
Avatar

From my understanding you have to use tap and then whitelist the dynamic fields. Here is the code I used in my application.

ruby
def product_type_params
      params.require(:product_type).permit(:name).tap do |whitelisted|
              whitelisted[:product_fields] = params[:product_type][:product_fields]
      end
end

Here is the resource I used to figure this out.
Link

I hope that helps.