Reputation: 1
I want to make what ActiveRecord validation errors highlighted in the browser takes a lesson from ASCIIcasts. This is my partial _errors_messages
<% if event.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(event.errors.count, "error") %> prohibited this record from being saved:</h2>
<ul>
<% event.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
this is my html file which is generated form
<%= form_for event, html: { class: "event-form" } do |f| %>
<%= render "shared/error_messages", :target => @event %>
<% unless current_user %>
<div class='row'>
<div class='col-md-4'>
<div class="form-group col-sm-12">
<%= label :email, "Enter your email:" %>
<%= text_field_tag :email, "",class: "form-control" %>
and this error browser show
undefined local variable or method `event' for #<#<Class:0x007f117cc78c30>:0x007f117cdf5c48>
Upvotes: 0
Views: 32
Reputation: 160201
event
should be an instance variable in the controller, e.g., @event
.
Upvotes: 1