Is it possible to use a scope as source for association with simple_form?

我的未来我决定 提交于 2019-12-07 03:57:26

Sorry, I don't think that will work. A scope returns an ActiveRecord::Relation and simple_form is looking for a symbol that represents an existing ActiveRecord::Association (E.g. has_many, belongs_to).

https://github.com/plataformatec/simple_form#associations

You can use collection for source

in controller

@active_users = User.active_users

in view

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