On Feb 10, 2012, at 3:57 PM, Christopher Jones wrote: > This is my user model: > > > class User < ActiveRecord::Base > has_one :profile > has_many :games > has_one :wishlist > > attr_accessor :password > before_save :encrypt_password > > validates_presence_of :username > validates_length_of :username, :within => 6..20, :message => "must > contain between 6 to 20 characters" > validates_uniqueness_of :username > validates_presence_of :email > validates_uniqueness_of :email > validates_format_of :email, :with => > /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i, :on => :create > validates_confirmation_of :password > validates_length_of :password, :within => 8..20, :message => "must > contain between 8 to 20 characters" > validates_presence_of :password, :on => :create > validates_presence_of :password_confirmation > > before_create :assign_wishlist > > private > def assign_wishlist > self.wishlist = Wishlist.create > end > > def encrypt_password > if password.present? > self.password_salt = BCrypt::Engine.generate_salt > self.password_hash = BCrypt::Engine.hash_secret(password, > password_salt) > end > end > > def self.authenticate(email, password) > user = find_by_email(email) > if user && user.password_hash == > BCrypt::Engine.hash_secret(password, user.password_salt) > user > else > nil > end > end > end > > > and the following is my wishlist model: > > class Wishlist < ActiveRecord::Base > belongs_to :user > validates_presence_of :number_1 > validates_presence_of :number_2 > validates_presence_of :number_3 > validates_presence_of :number_4 > validates_presence_of :number_5
This is your problem right here. Your validations aren't passing because nothing is being added to the wishlist in my code. Do you have these values (number_1 etc) at the moment that the user is being created? If so, where do they live at that precise moment? Walter > > end > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.