ActionView::Helpers::FormHelper methods (e.g. #text_field,
#check_box…) take object_name as an argument. From this argument
they infer a name that is supposed to contains the reference to the
I can’t see why the FormHelper methods were designed that way.
Compared to simply passing them a reference, the current way seems too
complicated and an invitation to problems or at least limitations.
For example, if you call text_field(“post”, “title”), the method would
look for a @post instance variable. Imagine you were using a local
variable for storing the relevant object, instead of an instance
variable. If text_field took a reference, you would just call it with
text_field(post, :title). However, since it takes a string an infers a
reference name, you now have to change your assigned names or at least
create new aliases to your existing names.
To sum up, I can’t see any advantages to the object_name approach, I
don’t understand why FormHelper was initially designed that way, so I
think it should be changed so as to be more convenient and flexible.
What do you think?