V
V
Vayladion Gognazdiak2018-05-16 15:00:30
Ruby on Rails
Vayladion Gognazdiak, 2018-05-16 15:00:30

Why doesn't it handle false in a callback in AA?

Droughty, Droughty, good afternoon.
There is ruby ​​2.1.4, rails 5, ActiveAdmin 2.0.0
ActiveAdmin has a callback:

ActiveAdmin.register Post do
  
  before_save do |post|
    post.errors.add :base, "You can't post this shit!"
    false
  end

end

In theory, an error should be added to errors and the creation of the record should be shortened.
In fact, we have the following - "You can't post this shit!" is added to errors, but the creation of the record still occurs.
Good people, where to dig, so as not to make this validation into the model?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Demidenko, 2018-05-16
@Dem1

Rails 5 fixed this and now you can't abort the save by returning false, but you can through
throw(:abort)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question