ruby on rails 3 - Why is user.save true but email shows as nil? -
I am using a nested model form for sign-up and working through kinks as a start I am A problem that came up specially, although I do not actually find it returning as Before I started playing with the nested model form, I can make a record in the console for a problem. Now, though I can not create records and the latest records are made in their email as If I go to Everything goes fine up to user.save, which gives me an error named in 25 User model is: Does anyone help me to understand what is happening? Update strong: I tried to change my regex, but I still I am seeing zero for the email, although a former SO post regex without any test So I probably did not test it properly, though: I no longer found any errors. ActiveRecord is defined by such "properties" as user.email back to
zero .
zero (I'm not sure there is nothing with the model in it, but this is my reference point When he starts messing up.)
Rail Console to create a new user / profile, I follow this process:
user = user. New user.mail = "" user.password = "" user.profile = profile.new user.profile.first_name = "" ... user.profile.save user.save
: Undefined local variable or # & lt; User: & gt; For the method 'parameter'
in the Rail Console, it pins user.rb:
create_profile
class user & lt; ActiveRecord :: Base attr_accessor: Password: Email has_one: Profile ,: Dependent = & gt; : Destroys accepts_nested_attributes_for: Profile Valid: email, uniqueness = & gt; True,: length = & gt; {: Inner = & gt; 5..50},: format = & gt; {: With = & gt; / ^ [^ @ <[\ W]] + @ [[w -] + [[]] [a-z] {2,4} $ / i} is valid: password, confirmation = & gt; True,: length = & gt; {: Inside 4..20} ,: = Appearance => True if, if & gt; :Password required? Before_save: encrypt_new_password after_save: create_profile def self.authenticate (email, password) user = find_by_email (email) comes back to the user if user & amp; Amp; User.authenticated? (Password) end deaf certified? (Password) self.hashed_password == encrypt (password end protected encry encrypted_nu_password return if password.blank? Self.hashed_password = encrypt (password) enddef password_required? Hashed_password.blank? ||
attr_accessor just a" property "and an activated code (
attributes a
hash )
attributes ) have no relation to the table).
attr_accessor . (Basically,
attr_accessor a
attr_reader and attr_
author (i.e. "getter" and "setter") at the same time define)
Comments
Post a Comment