I'm following the Rails Guide to implement this, but I'm getting this error, and I'm not entirely sure how to fix it.
Error display in form:
<% if @group.errors.any? %>
<div id="error_exp">
<h2><%= pluralize(@group.errors.count, "error") %> prohibited this article from being saved:</h2>
<ul>
<% @group.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
Controller create action: (I'm testing the error display on a new group form)
def create
@group = current_user.groups.build(group_params)
if @group.save
redirect_to user_groups_path(current_user)
else
render :new
end
end
Model validations:
class Group < ApplicationRecord
has_many :cards, dependent: :destroy
belongs_to :category
belongs_to :user
end
class Category < ApplicationRecord
has_many :groups
has_many :users, through: :groups
validates :name, presence: true
validates_uniqueness_of :name, :case_sensitive => false
end
class Card < ApplicationRecord
belongs_to :group
validates :front,:back, presence: true
end
Thank you for the help!
question from:
https://stackoverflow.com/questions/65830021/validation-error-display-is-producing-this-undefined-method-full-message-for 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…