语法错误Ruby简单表单相关字段gem Haml

时间:2019-02-13 16:48:33

标签: javascript ruby-on-rails field simple-form

我是Rails新手,尝试实现从属字段gem。我一直在关注本教程,但仍会发现语法错误。

我是Ruby Haml仅供参考

https://www.rubydoc.info/gems/dependent-fields-rails/0.4.2

我只尝试了本教程中提到的内容,但遇到以下错误

app / views / houses / _form.html.haml:8:语法错误,出现意外的tIDENTIFIER,预期为“)” app / views / houses / _form.html.haml:8:语法错误,出现意外的“)”,需要keyword_end app / views / houses / new.html.haml:4:in'_app_views_houses_new_html_haml ___ 583738311_56256552'

这是我的houses_form.erb.haml

= simple_form_for @house do |f|
  = f.input :doorno, :label => "House No or Name:"
  = f.input :house_title, :label => "Street Name:"
  = f.input :postcode, :label => "Post Code:"
  = f.input :description, :label => "Description:"
  = f.input :price, as: :currency, :inline_label => "Price:"
  = f.input :occupied, inline_label: 'Tick if the Property Occupied'
  .js-dependent-fields{data-checkbox-id='house_occupied' data-checkbox- 
   value='true'}
    = f.association :tenant, :label => "Tenant Name:"
  = f.button :submit, class: "button"

租户字段仅显示是否选中了已占用的框

application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require underscore
//= require dependent-fields

$(document).ready(function() {
DependentFields.bind()
}

试图将{}更改为[],仍然存在类似的语法错误

1 个答案:

答案 0 :(得分:0)

您似乎在{}通话中使用.js-dependent-fields。尝试将{}更改为[]