Reputation: 9
I want to call a function after a particular form is submitted in my mobile app. I am calling it as :
after_save :insert_into_my_table, on: :save_playing_request
save_playing_request is the function which saves the new form. I want to call insert_into_my_table after this. Is it the correct way?
Upvotes: 0
Views: 33
Reputation: 441
It is not correct way, I think you should use conditional callback or you can also try to customize this as per your requirement.
Like below code.
save_playing_request is just save the data then it should return true/false. then we can use 'if' with callback.
after_save :insert_into_my_table, if: :save_playing_request?
Now you need to change your method name.
save_playing_request => save_playing_request?
Upvotes: 1