** Day 21 of Calendar Planning 2020 ** It's been about 3 months since I started studying programming, so I will leave a note of what I learned in the article as an output. I would be happy if I could help anyone entering the world of programming. Please let me know if there are any words that are wrong, wrong, or misunderstood ^^ I'm sorry if it's hard to read the words for a long time. I will do my best to get used to it little by little.
I got this error when I created a custom validation. (It's my complete mistake ^^;)
environment
Rails 5.2.4.4
ruby 2.6.3
demo.rb
validates :demo
validates :body, presence: true
def demo
#Since it is not related to this case, it is omitted.
end
With this
I get this error ^^;
demo.rb
validate :demo
validates :body, presence: true
def demo
#Since it is not related to this case, it is omitted.
end
that's all!
It seems that it was validate
instead of validates
.
The problem was that s
was extra.
Standard validation is like validates
.
(If you use it often, the space is on the second line of the example that it is useless)
The custom validation seems to be validate
.
I wrote a memo so that people who made the same mistake can solve it early. Please refer to it if you like.