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 user.email back to zero .

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 zero (I'm not sure there is nothing with the model in it, but this is my reference point When he starts messing up.)

If I go to 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   

Everything goes fine up to user.save, which gives me an error named : Undefined local variable or # & lt; User: & gt; For the method 'parameter' in the Rail Console, it pins user.rb: create_profile

in 25 User model is:

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

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.

attr_accessor just a" property "and an activated code ( attributes a hash ) attributes ) have no relation to the table).

ActiveRecord is defined by such "properties" as attr_accessor . (Basically, attr_accessor a attr_reader and attr_ author (i.e. "getter" and "setter") at the same time define)

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

memcached - Django cache performance -

java : convert string value to int -