What we're listening to:
Jared

The Hold Steady:
Heaven Is Whenever
Jeff

Paper Route:
Absence

form_builder tip

June 16th, 2008

I ran into a situation this week where I had a single partial containing form fields being rendered for different models. Inside that partial, one of the fields was a text_field_with_autocomplete, which presented a problem, since form_builder doesn’t know anything about text_field_with auto_complete, and the text field certainly needed to know what model we were working with here. After a little digging, turns out form_builder exposes a getter called object_name:

<%= text_field_with_auto_complete f.object_name, :city_name, ... %>

Easy.

blog comments powered by Disqus