Rails 3.2 - collection_select Adding A Null Entry In The First Position Of My Array

試著忘記壹切 提交于 2019-12-07 02:52:32
Pamela Cook - LightBe Corp

According to @vinodadhikary the null entry in the array is working as expected in Rails 3. I recently rewrote this application in Rails 4. I completely rewrote the logic by first using has_many through to relate all my tables. I also replaced the fields_for logic by just using a collection_select statement. I added include_hidden = false in the first {} and the null entry does not appear in the array. I asked a similar question a few days ago and after a lot of searching I came up with a solution. Details are in the link below.

Rails 4 - Using collection_select to get an array of ids for an Intermediate Table with Nested Attributes

Try params[:media_topic][:topic_ids].delete("") in your controller before the update action.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!