0

我需要我的 Rails 代码来呈现它的一个表单字段,如下所示:

contacts[:custom_field][phone_number]

我已经尝试了各种方法来让它在我的模板文件中工作:

:custom_field=> :phone_number

我在我的 HTML 中得到了这个:

name="contacts[{:custom_field=>:license_1234, :class=>"text_field width_100_percent"}]"

ID应该看起来像

id="helpdesk_ticket_custom_field_phone_number_50754"

但是,当我提交表单时,我收到一条错误消息,说它无法连接到 API。

 Freshdesk::ConnectionError in Website::ContactsController#create

 Connection to the server failed. Please check hostname

当我在控制台中执行此操作时

  contacts.post_tickets(name: "John Doe", email: 'user@exmaple.net', :custom_field=>{:phone_number=>"123-123-1234"})

有用!和帖子,但我似乎无法在我的实际代码中复制它

html

= form_for(:contacts, url: contacts_path) do |f|
  = f.label "Name"
  %br
  = f.text_field :subject, class: "text_field width_100_percent"
  %br
  %br    
  = f.label "Email"
  %br    
  = f.email_field :email, class: "text_field width_100_percent"
  %br
  %br
  = f.label "Phone"
  %br    
  = f.text_field :custom_field=>{:phone_number_50754=>"AMD-123"}
  %br
  %br
  = f.label "Question(s), and/or feedback"
  %br
  = f.text_area :description, class: "text_field width_100_percent"
  %br
  %br
  = f.submit "Submit", class: 'btn btn-warning'
4

0 回答 0