私はcheckbox.Hereとフォームの形式である:それがないと思われRails:フォーム上で未定義のメソッドエラーを修正する方法は?
undefined method `actif' for #<User:0x007fadc2674c48>
Extracted source (around line #35):
<div class="field">
<%= f.label :actif %> <br />
<%= f.check_box :actif, {}, true, false %> <br />
</div>
:http://localhost:3000/users/3/edit
が、私は次のエラーを持っている:
<div class="border-form-div">
<%= form_for(@user, class: "form-horizontal") do |f| %>
<% if @user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% @user.errors.each do |attribute,message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<% if @user.role == "candidat" %>
<%= f.fields_for :profileable do |pf| %>
<div class="field">
<%= f.label :actif %> <br />
<%= f.check_box :actif, {}, true, false %> <br />
</div>
<% end %>
<br>
<div class="actions">
<%= f.submit "Mettre à jour",class: 'btn btn-primary' %>
</div>
<% end %>
</div>
私はページを編集するために行きたいですactifを属性として認識しません。何が問題なの? Actifは私のモデルとフォームに追加されたフィールドです。
移行を実行しましたか? –
はい移行を実行し、actif属性 – Pracede
にデフォルト値を追加してサイトを再起動しましたか? –