I'm following rails cast #263 for client side validations and am trying to make them come out onto the screen for my posts. Everything seemed fine so far, but when I go to posts new I get the error
ArgumentError in Posts#new
wrong number of arguments (3 for 2)
Extracted source (around line #1):
<%= form_for @post, :validate => true, :html => {:multipart => true} do |f| %>
here is a copy of my post _form
<%= form_for @post, :validate => true, :html => {:multipart => true} do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :title %><br>
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.file_field :image %>
</div>
<div class="field">
<%= f.label :content %><br>
<%= f.text_area :content %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
application.htm.erb file
<!DOCTYPE html>
<html>
<head>
<title>Blog</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "rails.validations", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
<%= favicon_link_tag 'favicon1.ico' %>
<%= render 'layouts/nav' %>
</head>
<body>
<%= yield %>
</body>
<footer>
<%= render 'layouts/footer' %>
</footer>
<br>
</html>
post model
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments
mount_uploader :image, ImageUploader
validates :title, presence: true,
length: { minimum: 5 }
validates :content, presence: true,
length: { minimum: 5 }
end
and my client_side_validations.rb file
# ClientSideValidations Initializer
# Uncomment to disable uniqueness validator, possible security issue
# ClientSideValidations::Config.disabled_validators = [:uniqueness]
# Uncomment to validate number format with current I18n locale
# ClientSideValidations::Config.number_format_with_locale = true
# Uncomment the following block if you want each input field to have the validation messages attached.
#
# Note: client_side_validation requires the error to be encapsulated within
# <label for="#{instance.send(:tag_id)}" class="message"></label>
#
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
unless html_tag =~ /^<label/
%{<div class="field_with_errors">#{html_tag}<label for="#{instance.send(:tag_id)}" class="message">#{instance.error_message.first}</label></div>}.html_safe
else
%{<div class="field_with_errors">#{html_tag}</div>}.html_safe
end
end
anyone here know what the problem is and or why its happening? Did I miss or spell something wrong?