NameError: undefined local variable or method `email' for #<Class:0x007fc3f35c4fe0>

I'm working through chapter six of Rails Tutorial (http://ruby.railstut...ness_validation) and am stuck at listing 6.20 due to the following error occurring when I attempt to perform any CRUD activity on my database:

"NameError: undefined local variable or method `email' for #<Class:0x007f9ddf15d0b8>"

Hi ExNihil, I'm also a newbie with Rails... just started this June/July learning Ruby, then Rails.

Using brackets instead of parentheses did the trick.

Brackets { } are used to pass code blocks, and in this case you're passing the code inside { } to the validates method. When you used parenthesis ( ), it's passing parameters/variables to the validates method... which in this case, is not what was expected. ... that's why you got the "undefined local variable"

I'm curious--is it a stylistic convention in Rails to not use parentheses wherever possible? I'm not the least bit opposed to it. I ask because I want to work within the conventions of the language.

Yes, in most cases parenthesis are not needed when calling functions/methods.

In some specific cases, you need parenthesis only to force Ruby to evaluate things in the order you want.

Also, sometimes curly brackets are not needed in some special circumstances, and Rails take advantage of these "features" to make everything succinct and your code clean looking.