There Are Four Lights
There Are Four Lights

Reputation: 1426

Formtastic, pre-modification of symbol

I have input/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.

Upvotes: 1

Views: 108

Answers (1)

KARASZI István
KARASZI István

Reputation: 31467

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

Upvotes: 1

Related Questions