Rollback Transaction Error - Rails -


Some classmates and I have some problems in our train app for class. Whenever we try the user to the user, then create the ROR app on Rail Console. After filling out the required form, we get a rollback transaction.

Any way to fix this? Here's the error:

  Rail Console development environment is loading (Rail 3.2.13) irb (main): 001: 0> Select User.count (0.0 mms) from COUNT (*) to "user" = & gt; 0 IRB (Main): 002: 0> User.create (name: "Mr. Rush", email: "rush@example.com", password: "firebar", password_confirmation: "fubar") (0.0ms) transaction user current (0.0ms) Select 1 Where "user" from one ("user". "Email") = LOWER ('rush@example.com ') LIMIT 1 (0.0 mms) rollback transaction = & gt; # & Lt; User ID: Zero, Name: "Mr. Rush", Email: "rush@example.com", Created_net: Zero, Updated: Zero, Password_Digest: "$ 2a $ 10 $ quwMA.4fcrBpg2sRy00qEOWrjHduAN0OZFvcXiCmNjUR ..." & gt ; IRB (Main): 003: 0>   

User.rb file

  Class user & lt; ActiveRecord :: Base attr_accessible: email,: name, password: password_confirmation has_secure_password before_save {| User | user.email = user.email.downcase} Valid: name, presence: true, length: {max: 30} VALID_EMAIL_REGEX = /\A[\w+\-\-.]+\.[az]+\z/i Valid: Email: Attendance: True, Format: {with: VALID_EMAIL_REGEX}, Specification: {case_ Sensitive: Incorrect} Valid: Password, Attendance: Right, Length: {Minimum: 5} Valid: Password_confirmation, Existence: Expiration    

Your user is failing to create because the email format failed verification.

This is interesting, though it reports this error as if the specificity is something that is causing the problem. You have shown your user table to keep the blank so that no specificity is limited.

Some things to try:

1) Try this in the console:

  user = user.new (name: "Mr. Rush ", Email:" rush@example.com ", password:" FAQ ", password_confirmation:" fubar ") user.valid? & Lt; --- You must give the wrong user Errors & lt; --- You must have wrong format of email   

When I add presence anything in a verifier I always allow the value to be empty in the following assumptions is; If this is mandatory, there is no point in validating the nature or specificity of something. I.e.

  valid: email, presence: true, format: {with: VALID_EMAIL_REGEX, allow_blank: true}, specification: {case_ sensitive: wrong, permission_ct: true}   

By doing so, or there may be no change in thinking about the true validation failure.

2) Fix regex for email verification. Confirming an email address by Regex is a little controversial, but you should know something like this:

  VALID_EMAIL_REGEX = / \ A [\ w + \ -.] + @ [Az \ d--.] + \. [Az] + \ z / i   

You can try regex validation using a website as usual.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -