0

I am not sure what went wrong as when user registers it shows a undefined method `code' error that points to ' if @user.save' from the users controller under def create. I have looked back at the history of my controller and nothing has changed. Not sure why it is breaking now or how to fix it.

user model:

  validates :code, uniqueness: true
  validates_format_of :zip_code,
                  with: /\A\d{5}-\d{4}|\A\d{5}\z/,
                  message: "should be 12345 or 12345-1234"
3
  • what's your User model look like? Commented Oct 2, 2013 at 18:54
  • I just added the user model Commented Oct 2, 2013 at 18:56
  • 3
    You're validating an attribute named :code. Are you sure it exists? Commented Oct 2, 2013 at 18:58

1 Answer 1

3

the only code in your code is here:

#user.rb
validates :code, uniqueness: true 

Did you add this later and forget to run rake db:migrate perhaps? or could there be multiple instances of :code with the same value?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.