【发布时间】:2010-06-03 09:55:02
【问题描述】:
我在 Formtastic 表单上有输入/选择
f.input :some_model_values, :as => :select
问题是我需要预先定义:some_model_values。因为有些用户角色必须查看所有列表,而有些则不需要。
如何实现?
谢谢。
【问题讨论】:
我在 Formtastic 表单上有输入/选择
f.input :some_model_values, :as => :select
问题是我需要预先定义:some_model_values。因为有些用户角色必须查看所有列表,而有些则不需要。
如何实现?
谢谢。
【问题讨论】:
在你看来:
f.input :property, :as => :select, :collection => get_property_collection(@user)
在你的助手中:
def get_property_collection(user)
case
when user.is_admin?
[ "foo", "bar" ]
else
[ "some", "thing" ]
end
end
【讨论】: