Method: Caprese::Query#get_record!
- Defined in:
- lib/caprese/controller/concerns/query.rb
#get_record!(scope, column, value) ⇒ Object
Note:
Fails with error 404 Not Found if the record was not found
Gets a record in a scope using a column/value to search by
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/caprese/controller/concerns/query.rb', line 144 def get_record!(scope, column, value) scope = record_scope(scope.to_sym) unless scope.respond_to?(:find_by!) begin scope.find_by!(column => value) unless scope.is_a?(Array) && scope.empty? rescue ActiveRecord::RecordNotFound => e fail RecordNotFoundError.new( model: scope.name.underscore, value: value ) end end |