From e13ca74df396010d5a980bd76495638fc9fbe818 Mon Sep 17 00:00:00 2001 From: wvengen Date: Tue, 29 Oct 2013 19:11:33 +0100 Subject: [PATCH] fix new user form --- app/models/user.rb | 4 ++-- app/views/shared/_user_form_fields.html.haml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 7335f925..f8df96cb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -27,8 +27,8 @@ class User < ActiveRecord::Base validates_presence_of :email validates_presence_of :password, :on => :create - validates_length_of :nick, :in => 2..25, :allow_nil => true - validates_uniqueness_of :nick, :case_sensitive => false, :allow_nil => true + validates_length_of :nick, :in => 2..25, :allow_nil => !FoodsoftConfig[:use_nick] + validates_uniqueness_of :nick, :case_sensitive => false, :allow_nil => !FoodsoftConfig[:use_nick] validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i validates_uniqueness_of :email, :case_sensitive => false validates_length_of :first_name, :in => 2..50 diff --git a/app/views/shared/_user_form_fields.html.haml b/app/views/shared/_user_form_fields.html.haml index e9924a63..56701874 100644 --- a/app/views/shared/_user_form_fields.html.haml +++ b/app/views/shared/_user_form_fields.html.haml @@ -1,5 +1,6 @@ -- unless FoodsoftConfig[:use_nick] == false - = f.input :nick +- if FoodsoftConfig[:use_nick] + -# use_nil option to user model validators break required mark + = f.input :nick, required: true = f.input :first_name = f.input :last_name = f.input :email