Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 试图创建新的表单帮助器以将类添加到文本字段中,但它没有';我好像没有把那门课加进去?_Ruby On Rails_Ruby_Forms_Helper - Fatal编程技术网

Ruby on rails 试图创建新的表单帮助器以将类添加到文本字段中,但它没有';我好像没有把那门课加进去?

Ruby on rails 试图创建新的表单帮助器以将类添加到文本字段中,但它没有';我好像没有把那门课加进去?,ruby-on-rails,ruby,forms,helper,Ruby On Rails,Ruby,Forms,Helper,这是助手: module FormHelper def phone_number_tag *args args.each do |e| if e.is_a? Hash and e.has_key? :class e[:class] = e[:class] + " phone_number" elsif e.is_a? Hash e[:class] = "phone_number" end end te

这是助手:

module FormHelper
  def phone_number_tag *args
    args.each do |e|
      if e.is_a? Hash and e.has_key? :class
        e[:class] = e[:class] + " phone_number"
      elsif e.is_a? Hash
        e[:class] = "phone_number"
      end
    end
    text_field_tag args
  end
end
奇怪的是,当我像这样把调试器扔进去的时候

module FormHelper
  def phone_number_tag *args
    args.each do |e|
      if e.is_a? Hash and e.has_key? :class
        e[:class] = e[:class] + " phone_number"
      elsif e.is_a? Hash
        e[:class] = "phone_number"
      end
    end
    debugger
    text_field_tag args
  end
end
。。。并在控制台中运行
text\u field\u tags args
,一旦它点击调试器,我会得到:

"<input id=\"_:first___:class___input_span2_phone_number___:placeholder___First__\" name=\"first {:class=&gt;&quot;input span2 phone_number&quot;, :placeholder=&gt;&quot;First&quot;}\" type=\"text\" />"
“”
但是,呈现页面上的HTML输出为:

<input class="input span2" id="follow_up_phone" name="referral[follow_ups_attributes][0][phone]" size="30" type="text">

即使在调试器中存在电话号码类,也没有电话号码类


有人知道为什么吗?

我认为应该是这样的:

text_field_tag *args

(带星号*)

如果你在课堂上使用“电话号码”怎么办?@SG86仍然不起作用