开发者

Formtastic, pre-modification of symbol

开发者 https://www.devze.com 2023-01-01 21:10 出处:网络
I have in开发者_运维技巧put/select on Formtastic form f.input :some_model_values, :as => :select

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

精彩评论

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