Ruby on rails 仅在生产中通过修补方法更新时模板错误的表单
我有一个与多个客户有很多关系的客户模型。我的表单对这些嵌套资源上的所有CRUD操作都使用build方法。一切都在当地运作;但是,当我部署到Heroku并尝试编辑任何资源(包括父帐户资源)时,我会得到一个关于语法的模板错误。我在Heroku上使用rails-V4.0.3、ruby-V2.0.0p247和Cedar堆栈。这是我的表格:Ruby on rails 仅在生产中通过修补方法更新时模板错误的表单,ruby-on-rails,ruby,ruby-on-rails-4,heroku,Ruby On Rails,Ruby,Ruby On Rails 4,Heroku,我有一个与多个客户有很多关系的客户模型。我的表单对这些嵌套资源上的所有CRUD操作都使用build方法。一切都在当地运作;但是,当我部署到Heroku并尝试编辑任何资源(包括父帐户资源)时,我会得到一个关于语法的模板错误。我在Heroku上使用rails-V4.0.3、ruby-V2.0.0p247和Cedar堆栈。这是我的表格: <div class="container"> <div class="row"> <div class="col-md-8
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2 well well-lg">
<div class="well well-lg" style="background: #fafafa;">
<h1 class="form-header">Pets</h1>
</div>
<%= form_for ([@account, @account.pets.build]), url: account_pet_path(@pet.account_id, @pet.id), method: :patch do |f| %>
<div class="well well-lg" style="background: #fafafa;">
<%= f.label :Name %><br>
<%= f.text_field :name, :value => @pet.name %><br>
<%= f.label :Type %><br>
<%= f.select :kind, options_for_select(['dog', 'cat', 'rabbit', 'fish', 'bird', 'hamster', 'gerbil', 'guineau pig', 'other']) %><br>
<%= f.label "Breed or kind" %><br>
<%= f.text_field :breed, :value => @pet.breed %>
</div>
<div class="well well-lg" style="background: #fafafa;">
<%= f.label :Age %><br>
<%= f.text_field :age, :value => @pet.age %><br>
<%= f.label "Birth month" %><br>
<%= f.text_field :birth_month, :value => @pet.birth_month %>
</div>
<div class="well well-lg" style="background: #fafafa;">
<%= f.label "Health history" %><br>
<%= f.text_area :health_history, :value => @pet.health_history %><br>
<%= f.label "Current health" %><br>
<%= f.text_area :current_health, :value => @pet.current_health %>
</div>
<div class="well well-lg" style="background: #fafafa;">
<%= f.label :Medications %><br>
<%= f.text_area :med_name, :value => @pet.med_name %><br>
<%= f.label "Medication procedure" %><br>
<%= f.text_area :med_administer, :value => @pet.med_administer %><br>
<%= f.label "Medication doses" %><br>
<%= f.text_area :med_dose, :value => @pet.med_dose %><br>
<%= f.text_area :med_frequency, :value => @pet.med_frequency %>
</div>
<div class="well well-lg" style="background: #fafafa;">
<%= f.label :Behavior %><br>
<%= f.text_area :behavior, :value => @pet.behavior %>
</div>
<p>
<%= f.submit :value => 'Update pet', :class => 'btn btn-primary' %>
<%= link_to 'Back', account_dashboard_path(@pet.account_id), :class => 'btn btn-primary' %>
</p>
<% end %>
</div>
</div>
</div>
以下是我在Heroku日志文件中得到的错误:
ActionView::Template::Error/app/app/views/pets/edit.html.erb:8:语法错误,意外关键字\u do,预期关键字\u end
…id,@pet.id,method::patch do | f |@output_buffer.safe_appe
/app/app/views/pets/edit.html.erb:50:语法错误,意外关键字\u确保,预期输入结束:
5: <h1 class="form-header">Pets</h1>
6: </div>
7:
8: <%= form_for ([@account, @account.pets.build]), url: account_pet_path(@pet.account_id, @pet.id), method: :patch do |f| %>
9: <div class="well well-lg" style="background: #fafafa;">
10: <%= f.label :Name %><br>
11: <%= f.text_field :name, :value => @pet.name %><br>
它不喜欢do,并且抱怨在我的代码erb:50语法错误的最后一行中需要关键字_end。但肯定有一个解决办法。我错过了什么明显的东西吗?Heroku和我的配置方式有什么奇怪之处吗?任何帮助都将不胜感激 您在时间之前有一个闭合圆括号。正确的语法应为:
<%= form_for ([@account, @account.pets.build], url: account_pet_path(@pet.account_id, @pet.id), method: :patch) do |f| %>
但是你也可以改进它,因为你已经有了一只宠物。无需在以下表单中创建一个:
<%= form_for ([@account, @pet], url: account_pet_path(@pet.account_id, @pet.id), method: :patch) do |f| %>