On Feb 10, 2012, at 4:55 PM, Christopher Jones wrote:

> Walter Davis wrote in post #1045281:
>> On Feb 10, 2012, at 3:57 PM, Christopher Jones wrote:
>> 
>>> 
>>> contain between 8 to 20 characters"
>>>   def encrypt_password
>>> BCrypt::Engine.hash_secret(password, user.password_salt)
>>> 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
> 
> These are in the wishlist table of the database, How would I go about 
> making them present?
> 

No, what I meant was, has the visitor typed them into a form field on the page? 
Where is the desired value coming from? Are these values present in the params 
hash when the form is being submitted?

If they're not there yet, and if you want the User to be created with or 
without a fully-populated wish list, then remove these validations and your 
wishlist will save as it did in my example.

Also, Colin is right, and I had written nearly the same thing but erased it 
because I wanted to solve one problem at a time. You really ought to be saving 
the individual wishlist_items as separate objects. Make another model called 
WishlistItem with belongs_to :wishlist, set Wishlist to has_many 
:wishlist_items and then you can make a nested form that will save one or many 
items to a wish list.

Walter

> -- 
> 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.

Reply via email to