I have a Rails 3 application I have been working on. I have a lot of forms which were all working perfectly. Its been a while since I have manually tested them in the browser. I made some CSS and style changes to the forms and flash messages to improve use and when I tested them I found that all of them are no longer working.
When the form is submitted with valid data there is no issue. But I found that when I submit invalid data and the form returns from validation you get the errors as expected but where there used to be Labels and Inputs there are now simply the words true (extremely strange).
I am wondering if anyone out there has ever experienced something as strange as this and if they know how to fix it?
Here are the screenshots
Pre-Submission missing required fields
Post-Submission returning with errors but Labels and Inputs no longer rendering
My form looks like this
<script language="javascript" type="text/javascript">
$(function() {
$('#weight_entry_date_time').datetimepicker( { dateFormat: 'yy-mm-dd', ampm: true } );
});
</script>
<%= form_for(@weight_entry) do |f| %>
<% if @weight_entry.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@weight_entry.errors.count, "error") %> prohibited this entry from being saved:</h2>
<ul>
<% @weight_entry.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div>
<% if current_user.profile.metric_scale? %>
Enter all values in Kilograms <br/> (you are using Metric Units)
<% else %>
Enter all values in Pounds <br/> (you are using American Units)
<% end %>
</div>
<% puts 'test: ' + f.inspect %>
<table class="entry">
<tr>
<td class="field_title required">
<%= f.label :weight %>
</td>
<td>
<%= f.text_field :weight %> (format: 0.000)
</td>
</tr>
<tr>
<td class="field_title required"><%= f.label :date_time, "Date/Time" %></td>
<td>
<% if @weight_entry.date_time %>
<%= f.text_field :date_time, :value => nice_date_form(@weight_entry.date_time) %>
<% else %>
<%= f.text_field :date_time %>
<% end %>
(format: yyyy-mm-dd hh:mm pm)
</td>
</tr>
</table>
<div class="actions">
<%= f.submit 'submit', :class => 'btn primary' %>
</div>
<% end %>
My Model looks like this
class WeightEntry < ActiveRecord::Base
attr_accessible :user_id, :weight, :date_time
# Relationships
belongs_to :user
# Validations
validates :user_id, :date_time, :presence => true
validates :weight, :presence => true, :numericality => { :greater_than => 0 }
end
Here are the GEMS I am including and using in the application
source 'http://rubygems.org'
# System Gems
gem 'rails', '3.0.9'
gem 'mysql2', '0.2.7'
gem 'seed-fu', '2.0.1'
# Security Gems
gem 'devise', '1.2.1'
gem 'cancan', '1.6.4'
gem 'recaptcha', '0.3.1', :require => 'recaptcha/rails'
gem 'rufus-mnemo', '1.2.0'
# Social Gems
gem 'gravatar_image_tag', '1.0.0.pre2'
# UI / AJAX Gems
gem 'jquery-rails', '>= 0.2.6'
gem 'will_paginate', '3.0.pre2'
gem 'client_side_validations', '3.0.4'
gem 'lazy_high_charts', '1.1.1'
# Utility Gems
# Testing Gems
gem 'faker', '0.3.1'
gem 'rspec-rails', '2.6.1', :group => [:test, :development]
group :test do
gem 'rspec', '2.6.0'
gem 'capybara', '1.0.0'
gem 'factory_girl_rails', '1.0.1'
gem 'populator', '1.0.0'
end