The question is in regard to the Rails tutorial. In particular I have a doubt about listing 6.23, this line:
before_save { |user| user.email = email.downcase }
I am curious about the variable “email” – where does it come from? Is it some kind of short Ruby syntax to call the left-hand side variable? Or does it call to the model’s attribute (it would make passing the block variable redundant though)?
I’d appreciate anyone ridding me of my confusion.
Yes, you can omit passing the user to the block
I personally prefer not using blocks and write named methods for this