Is it possible to make a dynamic Rails crawler throw an ActiveRecord::RecordNotFound exception rather than return nil when it cannot find the result?
For example, where a drink named "Nuka-Cola" does not exist:
@not_found = Beverage.find_by_name('Nuka–Cola')
Instead
@not_found == nil
Can
.find_by_name('Nuka–Cola')
throw throw method call ActiveRecord::RecordNotFound ?
Or will I need to check nil and throw an exception manually?
ruby ruby-on-rails activerecord exception
stephenallred
source share