ruby on rails - Display conditional values in a Formtastic select -


How do I direct formattolic selection to display values ​​only on a condition?

  - Semantic_form_for @member do | F | | - f.inputs do = f.input: person = f.input: role,: include_blank = & gt; False = f.input: active  

I only want to: List / Select the person input that is active i.e. Person.active == true. I did not try to pass a mash of a condition.

This is a two step process.

First you should only mean to choose people who are active then after that you have to pass the collection of active objects on the formattical input through the collection option.

Steps to choose only active people: this Person.find (: all :, as simple as: terms ["active =?", True]) . But I think this model is better than the nominated area.

  class person & lt; ActiveRecord :: Base # ... named_scope: active, terms = & gt; {: Active = & gt; True} End  

is now Person.active as it is Person.find (: all :: conditions ["active =?", True] )

Step two, Update the form:

  - semantic_form_for @member do | F | - f.inputs do = f.input: person ,: collection = & gt; Person.active = f.input: Role,: include_blank = & gt; False = f.input: active  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -