Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. COIt gets linked and stored into the database as it should. I'm intentionally failing validation by passing a bad email as the problem originally suggests. If I pass a proper email that passes the regex, then I don't get an error. The point here is to *intentionally* fail, and get the appropriate message into the view.
      singulars
    2. COI understand you are deliberately failing the example. I don't think you understand my point. Why have you made the add_student method a class method? In Ruby, self points to the class object in class methods, so the message add_student, while being sent to the instance object, executes with self pointing to the class object rather than the instance object. Perhaps ActiveRecord manages to do the right thing despite this, but unless I'm missing something, the method should not be a class method. I would be grateful if you could tell me what I'm missing.
      singulars
    3. COOK, I understand now. The add_student method cannot be a class method; that was a typo in your example. If you send a class method message to an instance object, you get NoMethodError. Rails doesn't recover from calling a class method on an instance object, at least in this case. The code you gave produces a NoMethodError in SchoolsController#create when I tried it out. Ruby instance objects do not see class methods because class methods are singleton methods for the class object. That's what I didn't understand, and now I do. Learn a thing a day, drive ignorance away!
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload