Skip to content

Instantly share code, notes, and snippets.

@paneq
Created December 28, 2011 17:56
Show Gist options
  • Save paneq/1528878 to your computer and use it in GitHub Desktop.
Save paneq/1528878 to your computer and use it in GitHub Desktop.
Initial situation
<%= form_for(@user) do |f| %>
<fieldset>
<div class="clearfix <%= @user.errors[:login].present? ? :error : nil %>">
<%= f.label :login %><br />
<div class="input">
<span class="help-block">
Your login. You know... login.
</span>
<%= f.text_field :login, :class => "xxlarge" %>
<% @user.errors[:login].each do |err| %>
<span class="help-block">
<p><%= err %></p>
</end>
<% end%>
</div>
</div>
</fieldset>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
class User < ActiveRecord::Base
validates :login, :length => { :in => 2..10 }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment