Html 在rails中生成自定义生成器

Html 在rails中生成自定义生成器,html,ruby-on-rails,ruby-on-rails-4,Html,Ruby On Rails,Ruby On Rails 4,我想在rails中为两个文本字段创建一个新的自定义生成器,用于rails中的range(segrated by-)字段 我试过类似的东西 <%= form_for :range, :url=>{:controller=>"skills",:action=>"create"},:html=>{:multipart => true}, :builder => ComponentBuilder do |f| %> <%= f.text_rang

我想在rails中为两个文本字段创建一个新的自定义生成器,用于rails中的range(segrated by-)字段

我试过类似的东西

<%= form_for :range, :url=>{:controller=>"skills",:action=>"create"},:html=>{:multipart => true}, :builder => ComponentBuilder do |f| %>


<%= f.text_range_field :min_value,:max_value, :value => min_value, :id => 'value-min' %>



<%end%>
{:controller=>“skills”、:action=>“create”}、:html=>{:multipart=>true}、:builder=>ComponentBuilder do | f |%>
最小值,:id=>'最小值'%>
我的自定义字段生成器类似于

class ComponentBuilder < ActionView::Helpers::FormBuilder
def text_range_field(obj1,obj2,label,*args)
opts = args.last.is_a?(Hash) ? args.pop : {}
human = (opts[:label] unless opts.blank?) || label.to_s.humanize
args << (opts[:class].blank?? opts.merge!({ class: "tab_general_input" }): opts)
mandatory_text = (opts[:mandatory] == true)? ("<span class=\"mandatory\"> *</span>") : ""
content_tag("ul" ,
  content_tag("li" ,
    content_tag("label" ,
      mandatory_text.html_safe + human.to_s.html_safe,
      for: "#{@object_name}_#{label}" ), class: "tab_general_title") +
    content_tag("li" ,text_field('','',*args)+text_field_tag('','',*args), class: "tab_general_info"))   

end
class ComponentBuilder