Answer the question
In order to leave comments, you need to log in
Why is the record not being added to the table?
I'm trying to add a record to a table.
First, I create a request:
result = model.build(
# Тут поля...
)
if result.save
puts 'Да'
else
puts 'Нет'
end
save
wrote: puts result.to_json
save
, it prints "No". Answer the question
In order to leave comments, you need to log in
Is there any way to get the text of the error?
Usually the error texts are inresult.errors.messages
Firstly
puts 'Нет'
puts result.errors.messages
valid_attributes = {foo: 1, bar: 2}
object = Object.create(valid_attributes)
expect(object).to be_valid
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question