2015-02-20 06:55:18 +01:00
class User < ActiveRecord :: Base
2015-03-14 06:33:49 +01:00
has_many :carts
2015-03-19 14:27:04 +01:00
has_many :children
accepts_nested_attributes_for :children
2015-03-19 22:29:16 +01:00
has_secure_password :validations = > false
2015-02-20 06:55:18 +01:00
2015-03-19 22:29:16 +01:00
validates :first_name , :presence = > { :message = > " Ime je obavezno polje. " }
validates :last_name , :presence = > { :message = > " Prezime je obavezno polje. " }
2015-02-20 06:55:18 +01:00
2015-03-19 22:29:16 +01:00
validates :email , :uniqueness = > { :case_sensitive = > false , :message = > " Već postoji registrovani korisnik sa email adresom koju ste unijeli. " } ,
format : { with : / \ A([^@ \ s]+)@((?:[-a-z0-9]+ \ .)+[a-z]{2,}) \ z /i , message : " Neispravna email adresa. " }
validates :password , :confirmation = > { :message = > " Šifre se ne podudaraju. " , :on = > :create } , length : { too_long : 'Šifra mora biti manja od 20 karaktera.' , in : 6 .. 20 , too_short : 'Šifra mora biti minimalne dužine od 6 karaktera.' }
2015-02-20 06:55:18 +01:00
end