开发者

Formtastic, pre-modification of symbol

I have in开发者_运维技巧put/select on Formtastic form

f.input :some_model_values, :as => :select

The problem is i need to pre define :some_model_values. Because some users roles have to see all list, and some others not.

How it can be done?

Thanks.


in your view:

f.input :property, :as => :select, :collection => get_property_collection(@user)

in your helper:

def get_property_collection(user)
  case
    when user.is_admin?
      [ "foo", "bar" ]
    else
      [ "some", "thing" ]
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜