changeset 64:9d42bcda8cea luisf

Validation of description fields (INCOMPLETE: error messages are not displayed correctly)
author luisf
date Mon, 06 Dec 2010 11:15:03 +0000
parents b5bd39e27658
children 69ee2e406f71
files app/models/ssamr_user_detail.rb app/models/user.rb app/views/account/register.rhtml
diffstat 3 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/app/models/ssamr_user_detail.rb	Fri Dec 03 13:14:12 2010 +0000
+++ b/app/models/ssamr_user_detail.rb	Mon Dec 06 11:15:03 2010 +0000
@@ -1,3 +1,5 @@
 class SsamrUserDetail < ActiveRecord::Base
   belongs_to :user
+
+  validates_presence_of :description
 end
--- a/app/models/user.rb	Fri Dec 03 13:14:12 2010 +0000
+++ b/app/models/user.rb	Mon Dec 06 11:15:03 2010 +0000
@@ -52,7 +52,7 @@
   belongs_to :auth_source
   
   has_one :ssamr_user_detail, :dependent => :destroy, :class_name => 'SsamrUserDetail'
-  
+
   # Active non-anonymous users scope
   named_scope :active, :conditions => "#{User.table_name}.status = #{STATUS_ACTIVE}"
   
--- a/app/views/account/register.rhtml	Fri Dec 03 13:14:12 2010 +0000
+++ b/app/views/account/register.rhtml	Mon Dec 06 11:15:03 2010 +0000
@@ -3,6 +3,12 @@
 <% form_tag({:action => 'register'}, :class => "tabular") do %>
 <%= error_messages_for 'user' %>
 
+<ul>
+  <% for message in @ssamr_user_details.errors.full_messages %>
+  <li><%= message %></li>
+<% end %>
+</ul>
+
 <div class="box">
 <!--[form:user]-->
 <% if @user.auth_source_id.nil? %>