Method: Apollo::ActiveRecordExtensions::ClassMethods#state_name_to_id
- Defined in:
- lib/apollo/active_record_extensions.rb
#state_name_to_id(state_name) ⇒ Object
66 67 68 69 70 |
# File 'lib/apollo/active_record_extensions.rb', line 66 def state_name_to_id(state_name) result = ActiveRecord::Base.connection.query "SELECT id FROM states WHERE klass = '#{self.to_s}' AND name = '#{state_name}'" raise "Cannot find state" if result.empty? result[0][0] end |