monkeypatching - Custom Form Elements in Rails -
Then I'm new to the rail and I'm trying to figure out what is the customized method of adding custom form elements Am Currently the way I am doing it is super grotty. I have seen it though (to) extension formulber punching of this duck Sounds like a better solution than Is there any other way to do this that does not need to copy some of the formula square directly into my custom?
class form :: application form builder & lt; ActionView :: Helpers :: Form Builder Form :: ApplicationHelper.instance_methods.each do | Selector | Src = & lt; & Lt; -end_src def # {selector} (method, option = {}) @ template.send (# {selector.inspect}, @object_name, method, objectify_options (option)) end end_src class_eval src, __FILE__, __LINE__ end personal def objectify_options ( Option): @ default_options.merge (options.merge (: object = & gt; @object)) end of end
Two parter here:
First of all, For new, I would recommend using the Formtastic gem. M.V.C is abused and neglected in V rail.
The formtest has been tested very well and support for Rail 3
With formstock you can increase custom elements to its magnificent class And can get the full host. Other benefits beyond ordinary field display
Second, being extended to the square is definitely acceptable. I like the module method because it is easy to see.
module form :: applicationformbilder class whateverYourExtending def some_special_method (stuff) # All types The end of the special content of
But I hardly know what I'm talking about here ... this is right on the edge of my understanding.
Just talked about the form and I like the formattic!
Comments
Post a Comment